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

fix #1032 by comparing string representations of types #1049

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

chavacava
Copy link
Collaborator

Closes #1032 by comparing string representations of types (and not relying on actual type information)

Failure messages were extended to provide the name of the type that can be omitted.
Failure position information were fixed to point to the type that can be omitted.

This new implementation of the rule spots more failures than the current implementation and it seems to not generate false positives.
The attached files contain the result of linting the telegraf codebase (cf #1032) with the current implementation and with the implementation proposed by this PR.
pr-result.txt
head-result.txt

Copy link
Collaborator

@denisvmedia denisvmedia left a comment

Choose a reason for hiding this comment

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

Lgtm

@denisvmedia
Copy link
Collaborator

We should also update the docs to remove the note I put there before.

Copy link

@zak-pawel zak-pawel left a comment

Choose a reason for hiding this comment

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

I tested this PR in the scenario from this issue: #1032
Your PR detects over 20 findings more (compared to what is now on master after this PR #1046 was merged), all findings are as valid as possible, zero false-positives.
Thanks!

failures = append(failures, lint.Failure{
Confidence: 1,
Node: field,
Node: prevType,

Choose a reason for hiding this comment

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

This change causes the first of the two compared arguments to be indicated in the results.
I don't know if this is a deliberate change, but it seems that it would be more consistent to indicate the first repeating argument (as it has been so far).

The same comment applies to return arguments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's a deliberated change; the intent is to be coherent with the message ("repeated ... type ... can be omitted") by pointing to the type that it can actually removed/omitted.

@chavacava
Copy link
Collaborator Author

I tested this PR in the scenario from this issue: #1032 Your PR detects over 20 findings more (compared to what is now on master after this PR #1046 was merged), all findings are as valid as possible, zero false-positives. Thanks!

@zak-pawel thanks for taking the time to test the PR.

@chavacava chavacava merged commit 4c3641e into mgechev:master Sep 24, 2024
4 checks passed
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.

The enforce-repeated-arg-type-style rule finds some false positives.
3 participants