-
Notifications
You must be signed in to change notification settings - Fork 1.8k
proposal: unnecesary_duplicate_value #59530
Copy link
Copy link
Closed
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposallinter-status-pendingtype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposallinter-status-pendingtype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Type
Fields
Give feedbackNo fields configured for issues without a type.
unnecesary_duplicate_value
Description
Remove unnecessary
||/&&values to avoid redundancy.Details
When the
||or&&operator is used with identical values, leading to redundant code, removing these unnecessary duplicates improves code clarity and reduces potential confusion. By enforcing this lint, developers are encouraged to write more concise and maintainable switch cases, eliminating redundancy without changing the logic of the program. This lint is particularly useful in ensuring that codebases remain clean and that unnecessary conditions do not obscure the intended logic.Kind
This lint enforces style advice by ensuring more concise and clear code, eliminating redundant conditions in switch cases.
Bad Examples
Good Examples
Discussion
Inspired by #59529 for cases of big or expressions where the values might not be exactly side by side and can be hard to spot. Usually, these cases appear when you are doing code refactoring so I believe this could help mainly in those cases.
This could of course have some false negatives but I believe it is best to have some kind of warning than to have none.
If this is ever implemented, I believe this should be added to
Effective Dart.Discussion checklist