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

Log raw lint evaluation output values. #199

Merged
merged 4 commits into from
Nov 28, 2022
Merged

Conversation

obi1kenobi
Copy link
Owner

Issue #193 was difficult to triage in part because not all of the values output by the lint query were included in the error message: the error message accidentally omitted the method name with the reported error, and only reported the type on which that method was defined.

It would make future triage easier if all values output by the lint query were made available together with their corresponding error messages.

This is "debug"-level logging output, extremely verbose even by the standards of the current --verbose flag. Should we add it to --verbose anyway, or should we add a new even-more-verbose setting (e.g. --debug or --verbose --verbose, whatever is better CLI design) and only output it in that case?

@obi1kenobi obi1kenobi requested a review from epage November 26, 2022 19:59
@obi1kenobi
Copy link
Owner Author

Here's an example of what the current implementation prints out:

--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: /~https://github.com/obi1kenobi/cargo-semver-check/tree/v0.13.0/src/queries/method_parameter_count_changed.ron

Failed in:
  test_crates::test_cases::parameter_count_changed::StructWithMethods::associated_function_with_a_parameter_added now takes 1 parameters instead of 0, in src/test_cases/parameter_count_changed.rs:26
    lint rule output values:
    {
      "current_parameter_count": [
        1
      ],
      "method_name": "associated_function_with_a_parameter_added",
      "method_visibility": "public",
      "name": "StructWithMethods",
      "non_matching_span_begin_line": [
        26
      ],
      "non_matching_span_filename": [
        "src/test_cases/parameter_count_changed.rs"
      ],
      "old_parameter_count": 0,
      "path": [
        "test_crates",
        "test_cases",
        "parameter_count_changed",
        "StructWithMethods"
      ],
      "span_begin_line": 23,
      "span_filename": "src/test_cases/parameter_count_changed.rs",
      "visibility_limit": "public"
    }
  test_crates::test_cases::parameter_count_changed::StructWithMethods::method_with_a_parameter_added now takes 2 parameters instead of 1, in src/test_cases/parameter_count_changed.rs:32
    lint rule output values:
    {
      "current_parameter_count": [
        2
      ],
      "method_name": "method_with_a_parameter_added",
      "method_visibility": "public",
      "name": "StructWithMethods",
      "non_matching_span_begin_line": [
        32
      ],
      "non_matching_span_filename": [
        "src/test_cases/parameter_count_changed.rs"
      ],
      "old_parameter_count": 1,
      "path": [
        "test_crates",
        "test_cases",
        "parameter_count_changed",
        "StructWithMethods"
      ],
      "span_begin_line": 29,
      "span_filename": "src/test_cases/parameter_count_changed.rs",
      "visibility_limit": "public"
    }
  test_crates::test_cases::parameter_count_changed::StructWithMethods::method_with_a_parameter_removed now takes 3 parameters instead of 4, in src/test_cases/parameter_count_changed.rs:38
    lint rule output values:
    {
      "current_parameter_count": [
        3
      ],
      "method_name": "method_with_a_parameter_removed",
      "method_visibility": "public",
      "name": "StructWithMethods",
      "non_matching_span_begin_line": [
        38
      ],
      "non_matching_span_filename": [
        "src/test_cases/parameter_count_changed.rs"
      ],
      "old_parameter_count": 4,
      "path": [
        "test_crates",
        "test_cases",
        "parameter_count_changed",
        "StructWithMethods"
      ],
      "span_begin_line": 35,
      "span_filename": "src/test_cases/parameter_count_changed.rs",
      "visibility_limit": "public"
    }
  test_crates::test_cases::parameter_count_changed::StructWithMethods::moved_trait_provided_method now takes 3 parameters instead of 2, in src/test_cases/parameter_count_changed.rs:49
    lint rule output values:
    {
      "current_parameter_count": [
        3
      ],
      "method_name": "moved_trait_provided_method",
      "method_visibility": "public",
      "name": "StructWithMethods",
      "non_matching_span_begin_line": [
        49
      ],
      "non_matching_span_filename": [
        "src/test_cases/parameter_count_changed.rs"
      ],
      "old_parameter_count": 2,
      "path": [
        "test_crates",
        "test_cases",
        "parameter_count_changed",
        "StructWithMethods"
      ],
      "span_begin_line": 41,
      "span_filename": "src/test_cases/parameter_count_changed.rs",
      "visibility_limit": "public"
    }
  test_crates::test_cases::parameter_count_changed::StructWithMethods::moved_method now takes 1 parameters instead of 2, in src/test_cases/parameter_count_changed.rs:56
    lint rule output values:
    {
      "current_parameter_count": [
        1
      ],
      "method_name": "moved_method",
      "method_visibility": "public",
      "name": "StructWithMethods",
      "non_matching_span_begin_line": [
        56
      ],
      "non_matching_span_filename": [
        "src/test_cases/parameter_count_changed.rs"
      ],
      "old_parameter_count": 2,
      "path": [
        "test_crates",
        "test_cases",
        "parameter_count_changed",
        "StructWithMethods"
      ],
      "span_begin_line": 44,
      "span_filename": "src/test_cases/parameter_count_changed.rs",
      "visibility_limit": "public"
    }

@epage
Copy link
Collaborator

epage commented Nov 26, 2022

This is "debug"-level logging output, extremely verbose even by the standards of the current --verbose flag. Should we add it to --verbose anyway, or should we add a new even-more-verbose setting (e.g. --debug or --verbose --verbose, whatever is better CLI design) and only output it in that case?

I think it could make sense to include it with "extra verbosity" / trace

verbosity: clap_verbosity_flag::Verbosity<clap_verbosity_flag::InfoLevel>, already allows returning Trace level. That can be given to config with a method for "extra verbose"

@obi1kenobi obi1kenobi marked this pull request as ready for review November 26, 2022 22:28
@obi1kenobi
Copy link
Owner Author

I tested this with -vv and it seemed to work as expected. I did read the docs but I'm still not that familiar with the clap ecosystem, so I'd love a review if you have a sec.

@obi1kenobi obi1kenobi merged commit b02bffb into main Nov 28, 2022
@obi1kenobi obi1kenobi deleted the log_raw_rule_eval_outputs branch November 28, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants