Skip to content

Commit e573fa2

Browse files
committed
build: force clippy on github actions and fixed current warnings
1 parent 8bcc258 commit e573fa2

File tree

10 files changed

+42
-10
lines changed

10 files changed

+42
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ let_and_return = "allow"
4444
redundant_closure = "allow"
4545
single_match = "allow"
4646
clone_on_copy = "allow"
47+
needless_lifetimes = "allow"

float-pigment-css/src/parser/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ fn parse_media_expression_series<'a, 't: 'a, 'i: 't>(
642642
return Ok(());
643643
}
644644
}
645-
return Err(parser.new_custom_error(CustomError::Unmatched));
645+
Err(parser.new_custom_error(CustomError::Unmatched))
646646
}) {
647647
Ok(_) => {}
648648
Err(err) => {
@@ -1667,7 +1667,7 @@ fn parse_attribute_flags<'a, 't: 'a, 'i: 't>(
16671667
_ => return Err(location.new_basic_unexpected_token_error(t.clone())),
16681668
})
16691669
} else {
1670-
return Err(location.new_basic_unexpected_token_error(t.clone()));
1670+
Err(location.new_basic_unexpected_token_error(t.clone()))
16711671
}
16721672
}
16731673
Err(_) => Ok(AttributeFlags::CaseSensitivityDependsOnName),

float-pigment-css/src/parser/property_value/calc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ pub(crate) struct ComputeCalcExpr<T> {
156156
impl ComputeCalcExpr<Angle> {
157157
pub fn try_compute(expr: &CalcExpr) -> Option<Angle> {
158158
match expr {
159-
CalcExpr::Angle(angle) => return Some(angle.as_ref().clone().to_rad()),
159+
CalcExpr::Angle(angle) => Some(angle.as_ref().clone().to_rad()),
160160
CalcExpr::Plus(l, r) | CalcExpr::Sub(l, r) => {
161161
let l = Self::try_compute(l)?;
162162

float-pigment-css/src/parser/property_value/gradient.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ pub(crate) fn gradient_repr<'a, 't: 'a, 'i: 't>(
436436
))
437437
}),
438438
_ => {
439-
return Err(parser.new_custom_error(CustomError::Unsupported));
439+
Err(parser.new_custom_error(CustomError::Unsupported))
440440
}
441441
}
442442
})

float-pigment-css/src/parser/property_value/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ pub(crate) fn element_func_repr<'a, 't: 'a, 'i: 't>(
861861
Ok(BackgroundImageItem::Element(hash.into()))
862862
}),
863863
_ => {
864-
return Err(parser.new_custom_error(CustomError::Unsupported));
864+
Err(parser.new_custom_error(CustomError::Unsupported))
865865
}
866866
}
867867
})
@@ -937,7 +937,7 @@ pub(crate) fn image_func_repr<'a, 't: 'a, 'i: 't>(
937937
Ok(BackgroundImageItem::Image(image_tags, image_src, color))
938938
}),
939939
_ => {
940-
return Err(parser.new_custom_error(CustomError::Unsupported));
940+
Err(parser.new_custom_error(CustomError::Unsupported))
941941
}
942942
}
943943
})

float-pigment-css/src/query.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ impl<L: LengthNum> MediaQueryStatus<L> {
8585
}
8686
}
8787

88+
/// The class for a `StyleNode`.
8889
pub trait StyleNodeClass {
90+
/// The name of the class.
8991
fn name(&self) -> &str;
92+
93+
/// The style scope of the class.
9094
fn scope(&self) -> Option<NonZeroUsize>;
9195
}
9296

@@ -100,19 +104,25 @@ impl StyleNodeClass for (String, Option<NonZeroUsize>) {
100104
}
101105
}
102106

107+
/// The case-sensitivity for attribute matching.
103108
pub enum StyleNodeAttributeCaseSensitivity {
109+
/// Case-sensitive.
104110
CaseSensitive,
111+
112+
/// Case-insensitive.
105113
CaseInsensitive,
106114
}
107115

108116
impl StyleNodeAttributeCaseSensitivity {
117+
/// Matches two strings with this case-sensitivity.
109118
pub fn eq(&self, a: &str, b: &str) -> bool {
110119
match self {
111120
Self::CaseSensitive => a == b,
112121
Self::CaseInsensitive => a.eq_ignore_ascii_case(b),
113122
}
114123
}
115124

125+
/// Check if `a` starts with `b` in this case-sensitivity.
116126
pub fn starts_with(&self, a: &str, b: &str) -> bool {
117127
// FIXME: reduce memory allocation
118128
match self {
@@ -121,6 +131,7 @@ impl StyleNodeAttributeCaseSensitivity {
121131
}
122132
}
123133

134+
/// Check if `a` ends with `b` in this case-sensitivity.
124135
pub fn ends_with(&self, a: &str, b: &str) -> bool {
125136
// FIXME: reduce memory allocation
126137
match self {
@@ -129,6 +140,7 @@ impl StyleNodeAttributeCaseSensitivity {
129140
}
130141
}
131142

143+
/// Check if `a` contains `b` in this case-sensitivity.
132144
pub fn contains(&self, a: &str, b: &str) -> bool {
133145
// FIXME: reduce memory allocation
134146
match self {
@@ -138,20 +150,38 @@ impl StyleNodeAttributeCaseSensitivity {
138150
}
139151
}
140152

153+
/// A node descriptor for a style query.
141154
pub trait StyleNode {
155+
/// The type for a class.
142156
type Class: StyleNodeClass;
157+
158+
/// The type for classes iteration.
143159
type ClassIter<'a>: Iterator<Item = &'a Self::Class>
144160
where
145161
Self: 'a;
146162

163+
/// The style scope of the node itself.
147164
fn style_scope(&self) -> Option<NonZeroUsize>;
165+
166+
/// The extra style scope of the node.
148167
fn extra_style_scope(&self) -> Option<NonZeroUsize>;
168+
169+
/// The extra style scope for the `:host` selector.
149170
fn host_style_scope(&self) -> Option<NonZeroUsize>;
171+
172+
/// The tag name of the node.
150173
fn tag_name(&self) -> &str;
174+
175+
/// The id of the node.
151176
fn id(&self) -> Option<&str>;
177+
178+
/// The classes of the node.
152179
fn classes(&self) -> Self::ClassIter<'_>;
180+
181+
/// Get an attribute of the node.
153182
fn attribute(&self, name: &str) -> Option<(&str, StyleNodeAttributeCaseSensitivity)>;
154183

184+
/// Check if the node has a specified scope.
155185
fn contain_scope(&self, scope: Option<NonZeroUsize>) -> bool {
156186
scope.is_none()
157187
|| self.style_scope() == scope
@@ -236,7 +266,7 @@ impl<'a> StyleNode for StyleQuery<'a> {
236266
self.classes.iter()
237267
}
238268

239-
fn attribute(&self, name: &str) -> Option<(&str, StyleNodeAttributeCaseSensitivity)> {
269+
fn attribute(&self, _name: &str) -> Option<(&str, StyleNodeAttributeCaseSensitivity)> {
240270
None
241271
}
242272
}
@@ -272,7 +302,7 @@ impl<'b, 'a: 'b> StyleNode for &'b StyleQuery<'a> {
272302
self.classes.iter()
273303
}
274304

275-
fn attribute(&self, name: &str) -> Option<(&str, StyleNodeAttributeCaseSensitivity)> {
305+
fn attribute(&self, _name: &str) -> Option<(&str, StyleNodeAttributeCaseSensitivity)> {
276306
None
277307
}
278308
}

float-pigment-css/src/sheet/rule.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ impl PropertyMeta {
186186
}
187187

188188
#[cfg(test)]
189+
#[doc(hidden)]
189190
pub fn property(&self) -> Option<Property> {
190191
match self {
191192
Self::Normal { property } | Self::Important { property } => Some(property.clone()),

float-pigment-css/src/sheet/selector.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ impl Selector {
449449
}
450450
}
451451
AttributeOperator::Hyphen => {
452+
#[allow(clippy::comparison_chain)]
452453
if element_attr_value.len()
453454
< selector_attr_value.len()
454455
{

float-pigment-css/tests/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::num::NonZeroUsize;
22

33
use float_pigment_css::query::{StyleNode, StyleNodeAttributeCaseSensitivity};
44
use float_pigment_css::{
5-
length_num::LengthNum, property::*, MediaQueryStatus, StyleQuery, StyleSheet, StyleSheetGroup,
5+
length_num::LengthNum, property::*, MediaQueryStatus, StyleSheet, StyleSheetGroup,
66
};
77

88
pub struct StyleQueryTest<'a> {

float-pigment-forest/src/ffi.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,6 @@ pub unsafe extern "C" fn NodeStyleSetRowGapCalcHandle(node: NodePtr, calc_handle
777777
/// # Safety
778778
///
779779
#[no_mangle]
780-
781780
pub unsafe extern "C" fn NodeStyleSetColumnGap(node: NodePtr, value: f32) {
782781
let node = &*(node.ptr as *mut Node);
783782
node.set_column_gap(DefLength::Points(Len::from_f32(value)));

0 commit comments

Comments
 (0)