Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy Compliance within Kani #1373

Closed
2 tasks done
YoshikiTakashima opened this issue Jul 12, 2022 · 8 comments · Fixed by #1466
Closed
2 tasks done

Clippy Compliance within Kani #1373

YoshikiTakashima opened this issue Jul 12, 2022 · 8 comments · Fixed by #1466
Assignees
Labels
[I] Refactoring / Clean Up Refactoring or cleaning up of existing code

Comments

@YoshikiTakashima
Copy link
Contributor

YoshikiTakashima commented Jul 12, 2022

As noted by @giltho & @celinval, there is a lot of clippy warnings in
Kani. This issue is for tracking compliance and tasks related to
measuring compliance.

  • Figure out which parts of Kani have Clippy warnings, and how many.
    • All 32 top-level hard errors come from kani-compiler.
      • This result does not conflict with people getting 100+ issues
        since these are top-level errors. Some errors may contain
        sub-errors, and we exclude all warnings.
    • When warnings are included, the breakdown is as follows.
      Screen Shot 2022-07-13 at 8 27 17 PM
{'library/kani': 3,
 'src': 55,
 'cprover_bindings': 17,
 'kani-driver': 6,
 'kani-compiler': 23,
 'tools/bookrunner': 5,
 'tools/compiletest': 44}
  • Add Clippy warnings to script/kani-regressions.sh. For now,
    explicitly ignore libraries that warnings, and incrementally
    remove them as they are fixed.
@YoshikiTakashima YoshikiTakashima added Type: Cleanup [I] Refactoring / Clean Up Refactoring or cleaning up of existing code and removed Type: Cleanup labels Jul 12, 2022
@YoshikiTakashima YoshikiTakashima self-assigned this Jul 13, 2022
@YoshikiTakashima
Copy link
Contributor Author

YoshikiTakashima commented Jul 13, 2022

Commands

cargo clippy --all  --message-format=json > clippy-logs.json-lines
cat clippy-logs.json-lines | \
   jq 'select(.message!=null) | select(.message.rendered | test(".*error:.*")) | .message' | \
   grep 'file_name'

The first line generates the logs in line-delimited json. The second
line selects log items that have messages that match errors. Third
line selects grep for file name field. (note, some of the structures
are recursive so grep is a bit quicker

@YoshikiTakashima
Copy link
Contributor Author

YoshikiTakashima commented Jul 14, 2022

@celinval Shall we enable -D warnings for clippy as well? I recall they are enabled for cargo build.

P.S. Will enable.

@YoshikiTakashima
Copy link
Contributor Author

For regression:

cargo clippy --all-targets --all-features -- -D warnings

@celinval
Copy link
Contributor

Yes, please go ahead and add them to the regression!

@YoshikiTakashima
Copy link
Contributor Author

As per discussion on #1389, we permanently will ignore these two.

@YoshikiTakashima The two lints are called expect_fun_call and or_fun_call.

@YoshikiTakashima
Copy link
Contributor Author

YoshikiTakashima commented Jul 22, 2022

For actual kinds of warnings:

cargo clippy --all --message-format=json  | \
jq 'select(.message!=null) | .message.code.code' | grep -v '^null$' | \
sort | uniq -c

Gives the following.

  54 "clippy::cargo_common_metadata"
   3 "clippy::collapsible_else_if"
   5 "clippy::derive_partial_eq_without_eq"
   1 "clippy::expect_fun_call"
   2 "clippy::format_push_string"
   1 "clippy::into_iter_on_ref"
   1 "clippy::iter_skip_next"
   1 "clippy::let_and_return"
   1 "clippy::manual_map"
   1 "clippy::manual_range_contains"
   1 "clippy::manual_strip"
   1 "clippy::missing_safety_doc"
   1 "clippy::module_inception"
   1 "clippy::needless_bool"
   3 "clippy::needless_borrow"
   1 "clippy::needless_range_loop"
   2 "clippy::new_without_default"
   3 "clippy::or_fun_call"
   1 "clippy::ptr_arg"
   1 "clippy::single_char_pattern"
   1 "clippy::vec_init_then_push"

@tedinski
Copy link
Contributor

For the cargo metadata one, I was irritated that it issued those warnings for all crates when I tried enabling it for just one.

But the simple fix there seems like it will ignore crates that are publish = false, so that's probably the expedient fix for those.

@YoshikiTakashima
Copy link
Contributor Author

After #1429

      5 "clippy::derive_partial_eq_without_eq"
      1 "clippy::manual_map"
      2 "clippy::map_entry"
      2 "clippy::module_inception"
      1 "clippy::new_ret_no_self"
      2 "clippy::new_without_default"
      1 "clippy::too_many_arguments"
      2 "clippy::type_complexity"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[I] Refactoring / Clean Up Refactoring or cleaning up of existing code
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants