Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,4 @@ LIBSTDBUF_DIR = "/usr/local/libexec/coreutils"

# remove me
[build]
rustflags = [
"-A",
"clippy::collapsible_if",
"-A",
"clippy::manual_is_multiple_of",
]
rustflags = ["-A", "clippy::collapsible_if"]
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
unused_qualifications = "warn"

[workspace.lints.clippy]
manual_is_multiple_of = { level = "allow", priority = 127 } # remove me
collapsible_if = { level = "allow", priority = 127 } # remove me
collapsible_if = { level = "allow", priority = 127 } # remove me
# The counts were generated with this command:
# cargo clippy --all-targets --workspace --message-format=json --quiet \
# | jq -r '.message.code.code | select(. != null and startswith("clippy::"))' \
Expand Down
2 changes: 1 addition & 1 deletion src/uu/df/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub(crate) fn to_magnitude_and_suffix(

if quot >= 100 && rem > 0 {
format!("{}{suffix}", quot + 1)
} else if rem % (bases[i] / 10) == 0 {
} else if rem.is_multiple_of(bases[i] / 10) {
format!("{quot}.{tenths_place}{suffix}")
} else if tenths_place + 1 == 10 || quot >= 10 {
let quot = quot + 1;
Expand Down
6 changes: 4 additions & 2 deletions src/uu/nl/src/nl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl SectionDelimiter {
fn parse(bytes: &[u8], pattern: &OsStr) -> Option<Self> {
let pattern = pattern.as_encoded_bytes();

if bytes.is_empty() || pattern.is_empty() || bytes.len() % pattern.len() != 0 {
if bytes.is_empty() || pattern.is_empty() || !bytes.len().is_multiple_of(pattern.len()) {
return None;
}

Expand Down Expand Up @@ -426,7 +426,9 @@ fn nl<T: Read>(reader: &mut BufReader<T>, stats: &mut Stats, settings: &Settings
NumberingStyle::All
if line.is_empty()
&& settings.join_blank_lines > 0
&& stats.consecutive_empty_lines % settings.join_blank_lines != 0 =>
&& !stats
.consecutive_empty_lines
.is_multiple_of(settings.join_blank_lines) =>
{
false
}
Expand Down
2 changes: 1 addition & 1 deletion src/uu/wc/src/count_fast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub(crate) fn count_bytes_fast<T: WordCountable>(handle: &mut T) -> (usize, Opti
&& stat.st_size > 0
{
let sys_page_size = unsafe { sysconf(_SC_PAGESIZE) as usize };
if stat.st_size as usize % sys_page_size > 0 {
if !(stat.st_size as usize).is_multiple_of(sys_page_size) {
// regular file or file from /proc, /sys and similar pseudo-filesystems
// with size that is NOT a multiple of system page size
return (stat.st_size as usize, None);
Expand Down
6 changes: 3 additions & 3 deletions src/uucore/src/lib/features/checksum/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl LineFormat {
// checksums that are fully alphanumeric. Another check happens later
// when we are provided with a length hint to detect ambiguous
// base64-encoded checksums.
if is_base64 && checksum.len() % 4 != 0 {
if is_base64 && !checksum.len().is_multiple_of(4) {
return None;
}

Expand Down Expand Up @@ -493,7 +493,7 @@ fn get_raw_expected_digest(checksum: &str, byte_len_hint: Option<usize>) -> Opti
// If the length of the digest is not a multiple of 2, then it must be
// improperly formatted (1 byte is 2 hex digits, and base64 strings should
// always be a multiple of 4).
if checksum.len() % 2 != 0 {
if !checksum.len().is_multiple_of(2) {
return None;
}

Expand All @@ -516,7 +516,7 @@ fn get_raw_expected_digest(checksum: &str, byte_len_hint: Option<usize>) -> Opti
// It is important to check it before trying to decode, because the
// forgiving mode of decoding will ignore if padding characters '=' are
// MISSING, but to match GNU's behavior, we must reject it.
if checksum.len() % 4 != 0 {
if !checksum.len().is_multiple_of(4) {
return None;
}

Expand Down
4 changes: 2 additions & 2 deletions src/uucore/src/lib/features/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl SupportsFastDecodeAndEncode for Base64SimdWrapper {
// If there are no more '=' bytes the tail might still be padded
// (len % 4 == 0) or purposely unpadded (GNU --ignore-garbage or
// concatenated streams), so select the matching alphabet.
let decoder = if remaining.len() % 4 == 0 {
let decoder = if remaining.len().is_multiple_of(4) {
Self::decode_with_standard
} else {
Self::decode_with_no_pad
Expand Down Expand Up @@ -448,7 +448,7 @@ impl SupportsFastDecodeAndEncode for Z85Wrapper {
fn encode_to_vec_deque(&self, input: &[u8], output: &mut VecDeque<u8>) -> UResult<()> {
// According to the spec we should not accept inputs whose len is not a multiple of 4.
// However, the z85 crate implements a padded encoding and accepts such inputs. We have to manually check for them.
if input.len() % 4 != 0 {
if !input.len().is_multiple_of(4) {
return Err(USimpleError::new(
1,
"error: invalid input (length must be multiple of 4 characters)".to_owned(),
Expand Down
Loading