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

refactor(config): fix warnings by 'cargo clippy' for config #1001

Merged
merged 1 commit into from
Jan 24, 2024

Conversation

octonawish-akcodes
Copy link
Contributor

@octonawish-akcodes octonawish-akcodes commented Jan 24, 2024

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

issue #191

2. What is the scope of this PR (e.g. component or file name):

KCLVM/config

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

Before:

abhi_ubuntu@MADHUSANJ:~/kcl1/kcl/kclvm/driver$ cargo clippy --fix --allow-dirty
    Checking kclvm-driver v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/driver)
warning: unnecessary `if let` since only the `Ok` variant of the iterator element is used
  --> driver/src/lib.rs:31:5
   |
31 |       for path in paths {
   |       ^           ----- help: try: `paths.flatten()`
   |  _____|
   | |
32 | |         if let Ok(path) = path {
33 | |             matched_files.push(path.to_string_lossy().to_string());
34 | |         }
35 | |     }
   | |_____^
   |
help: ...and remove the `if let` statement in the for loop
  --> driver/src/lib.rs:32:9
   |
32 | /         if let Ok(path) = path {
33 | |             matched_files.push(path.to_string_lossy().to_string());
34 | |         }
   | |_________^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
   = note: `#[warn(clippy::manual_flatten)]` on by default

warning: you seem to use `.enumerate()` and immediately discard the index
  --> driver/src/lib.rs:64:22
   |
64 |     for (_, file) in k_files.iter().enumerate() {
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_enumerate_index
   = note: `#[warn(clippy::unused_enumerate_index)]` on by default
help: remove the `.enumerate()` call
   |
64 |     for file in k_files.iter() {
   |         ~~~~    ~~~~~~~~~~~~~~

warning: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
   --> driver/src/lib.rs:207:29
    |
207 | pub fn lookup_kcl_yaml(dir: &PathBuf) -> io::Result<PathBuf> {
    |                             ^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
    = note: `#[warn(clippy::ptr_arg)]` on by default
help: change this to
    |
207 ~ pub fn lookup_kcl_yaml(dir: &Path) -> io::Result<PathBuf> {
208 ~     let mut path = dir.to_path_buf();
    |

warning: `kclvm-driver` (lib) generated 3 warnings
warning: `assert_eq` of unit values detected. This will always succeed
  --> driver/src/tests.rs:79:5
   |
79 | /     assert_eq!(
80 | |         expand_input_files(&input_files).sort(),
81 | |         expected_files.sort()
82 | |     );
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_cmp
   = note: `#[warn(clippy::unit_cmp)]` on by default

warning: `assert_eq` of unit values detected. This will always succeed
   --> driver/src/tests.rs:115:5
    |
115 | /     assert_eq!(
116 | |         expand_input_files(&input_files).sort(),
117 | |         expected_files.sort()
118 | |     );
    | |_____^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_cmp

warning: `kclvm-driver` (lib test) generated 5 warnings (3 duplicates)
    Finished dev [unoptimized + debuginfo] target(s) in 1.74s
warning: the following packages contain code that will be rejected by a future version of Rust: rustc-serialize v0.3.24
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
abhi_ubuntu@MADHUSANJ:~/kcl1/kcl/kclvm/driver$ cd .
abhi_ubuntu@MADHUSANJ:~/kcl1/kcl/kclvm/driver$ cd ..
abhi_ubuntu@MADHUSANJ:~/kcl1/kcl/kclvm$ cd config
abhi_ubuntu@MADHUSANJ:~/kcl1/kcl/kclvm/config$ cargo clippy --fix --allow-dirty
    Checking rustc_data_structures v0.0.1
    Checking kclvm-runtime v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/runtime)
   Compiling kclvm-version v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/version)
    Checking rustc_span v0.0.1
    Checking compiler_base_span v0.0.1
    Checking compiler_base_span v0.0.2 (/home/abhi_ubuntu/kcl1/kcl/compiler_base/span)
    Checking compiler_base_error v0.0.10
    Checking kclvm-span v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/span)
    Checking compiler_base_session v0.0.13 (/home/abhi_ubuntu/kcl1/kcl/compiler_base/session)
    Checking kclvm-error v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/error)
    Checking kclvm-ast v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/ast)
    Checking kclvm-config v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/config)
       Fixed config/src/modfile.rs (2 fixes)
       Fixed config/src/path.rs (5 fixes)
       Fixed config/src/cache.rs (1 fix)
warning: the borrowed expression implements the required traits
   --> config/src/path.rs:139:31
    |
139 |                         .join(&sub_path)
    |                               ^^^^^^^^^ help: change this to: `sub_path`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
    = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default

warning: `kclvm-config` (lib) generated 1 warning (run `cargo clippy --fix --lib -p kclvm-config` to apply 1 suggestion)
       Fixed config/src/settings.rs (1 fix)
       Fixed config/src/path.rs (8 fixes)
    Finished dev [unoptimized + debuginfo] target(s) in 7.42s
warning: the following packages contain code that will be rejected by a future version of Rust: rustc-serialize v0.3.24
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
abhi_ubuntu@MADHUSANJ:~/kcl1/kcl/kclvm/config$ cargo clippy --fix --allow-dirty
    Checking kclvm-config v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/config)
       Fixed config/src/cache.rs (1 fix)
       Fixed config/src/path.rs (5 fixes)
       Fixed config/src/modfile.rs (2 fixes)
warning: the borrowed expression implements the required traits
   --> config/src/path.rs:139:31
    |
139 |                         .join(&sub_path)
    |                               ^^^^^^^^^ help: change this to: `sub_path`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
    = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default

       Fixed config/src/settings.rs (1 fix)
       Fixed config/src/path.rs (8 fixes)
warning: `kclvm-config` (lib) generated 1 warning (run `cargo clippy --fix --lib -p kclvm-config` to apply 1 suggestion)
    Finished dev [unoptimized + debuginfo] target(s) in 2.17s
warning: the following packages contain code that will be rejected by a future version of Rust: rustc-serialize v0.3.24
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`

After:

abhi_ubuntu@MADHUSANJ:~/kcl1/kcl/kclvm/config$ cargo clippy --fix --allow-dirty
    Checking kclvm-config v0.7.4 (/home/abhi_ubuntu/kcl1/kcl/kclvm/config)
    Finished dev [unoptimized + debuginfo] target(s) in 2.37s
warning: the following packages contain code that will be rejected by a future version of Rust: rustc-serialize v0.3.24
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`

Signed-off-by: Abhishek Kumar <abhishek22512@gmail.com>
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 7639362436

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 87.787%

Totals Coverage Status
Change from base Build 7638731554: 0.0%
Covered Lines: 2293
Relevant Lines: 2612

💛 - Coveralls

Copy link
Contributor

@Peefy Peefy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 7639362439

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-15.4%) to 72.349%

Totals Coverage Status
Change from base Build 7638731554: -15.4%
Covered Lines: 43729
Relevant Lines: 60442

💛 - Coveralls

@Peefy Peefy merged commit ffcc5d9 into kcl-lang:main Jan 24, 2024
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants