icu4x icon indicating copy to clipboard operation
icu4x copied to clipboard

Resolve inline Clippy lints (comment explaining why it is OK or code changes)

Open ozghimire opened this issue 3 years ago • 8 comments

As part of resolving issue #1363 , codebase needs a lot of inline allow clippy code. This is expected to touch all production code folders.

Solution : The resolution strategy is either a well written comment explaining why it's ok or necessary code change to remove inline allow.

ozghimire avatar Mar 04 '22 20:03 ozghimire

@robertbastian will clean up low-hanging fruit, and create child issues for each component

sffc avatar Aug 18 '22 17:08 sffc

These are all the remaining undocumented lints that I couldn't fix. Please fix them or tell me how to.

  • [x] icu_calendar, @Manishearth
    • [x] Ethiopian::ethiopian_from_fixed
  • [ ] icu_datetime, @zbraniecki ?
    • [ ] Parser::handle_generic_quoted_literal
    • [ ] Parser::collect_generic_segment
    • [ ] PatternPlurals::expect_pattern (looks like an intended panic)
    • [ ] skeleton::helpers::create_best_pattern_for_fields
    • [ ] skeleton::helpers::get_best_available_format_pattern (x2)
  • [ ] icu_plurals, @zbraniecki ?
    • [ ] Lexer::advance_token
    • [ ] Rule
    • [ ] From<&Value> for u32
    • [ ] internal::to_icu4x_operands
  • [x] fixed_decimal, @younies
    • [x] Sign
    • [x] FromStr for FixedDecimal (x3)
    • [x] DoublePrecision
  • [x] zerovec, @Manishearth, @sffc
    • [ ] #1410

robertbastian avatar Aug 22 '22 13:08 robertbastian

zerovec and calendars in #2435

Manishearth avatar Aug 22 '22 21:08 Manishearth

@zbraniecki Assigning this to you since the remaining work is all in components you own.

sffc avatar Sep 15 '22 18:09 sffc

Why do we require comment to be added to panic!() which has content string?

It feels weird to have:

panic!("We panic because X");

have to be turned to:

panic!("We panic because of X"); // We panic because of X

zbraniecki avatar Sep 16 '22 20:09 zbraniecki

@zbraniecki to me, the panic message is for the user, and the comment is for us. If they're redundant it feels fine to not comment it IMO.

Manishearth avatar Sep 16 '22 20:09 Manishearth

@zbraniecki I've raised that concern before (also for expect) but the consensus of the group has been to require suppressions for all four (unwrap, expect, panic, and indexing_slicing).

sffc avatar Sep 16 '22 20:09 sffc

For example, the following is the style we're going for: the comment and the panic message are disjoint

/// # Panics
/// Panics if idx is not in bounds
fn get(idx: usize) {
  if idx >= self.len() {
    #[allow(clippy::panic)] // documented
    panic!("index must be in bounds");
  }
  // ...
}

sffc avatar Sep 16 '22 20:09 sffc