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

Add exhaustiveness check for config validation #5089

Merged
merged 10 commits into from Aug 21, 2022

Conversation

marschwar
Copy link
Contributor

@marschwar marschwar commented Jul 17, 2022

closes #4873

I know this is a completely different approach than originally outlined and quite a change set but it turned out that checking for exhaustiveness could just be a part of to already existing config validation. If this is not the direction we want to go, just let me know. It is totally fine.

Refactoring prior to adding the feature:

  • I moved everything that is concerned with config validation to the package config/validation.
  • I refactored the config validation function (in ValidateConfig.kt) into separate config validators (one for invalid properties and one for deprecated properties)

The feature itself:

  • Added a checkExhaustiveness: false to the config block in the detekt default configuration
  • If validation is true this flag is also true a new validator checks if all rules from the default configuration are mentioned in the user config (unless the entire rule set is marked as active: false)

@codecov
Copy link

codecov bot commented Jul 18, 2022

Codecov Report

Merging #5089 (bddc965) into main (829fae2) will increase coverage by 84.92%.
The diff coverage is n/a.

Current head bddc965 differs from pull request most recent head 3f0c6e9. Consider uploading reports for the commit 3f0c6e9 to get more accurate results

@@             Coverage Diff             @@
##             main    #5089       +/-   ##
===========================================
+ Coverage        0   84.92%   +84.92%     
- Complexity      0     3613     +3613     
===========================================
  Files           0      502      +502     
  Lines           0    11886    +11886     
  Branches        0     2237     +2237     
===========================================
+ Hits            0    10094    +10094     
- Misses          0      689      +689     
- Partials        0     1103     +1103     
Impacted Files Coverage Δ
...rbosch/detekt/rules/naming/ObjectPropertyNaming.kt 100.00% <0.00%> (ø)
...tekt/formatting/wrappers/SpacingAroundOperators.kt 100.00% <0.00%> (ø)
.../exceptions/ExceptionRaisedInUnexpectedLocation.kt 95.65% <0.00%> (ø)
...kotlin/io/gitlab/arturbosch/detekt/api/Severity.kt 100.00% <0.00%> (ø)
...n/io/github/detekt/metrics/processors/util/LLOC.kt 80.00% <0.00%> (ø)
...etekt/rules/coroutines/RedundantSuspendModifier.kt 65.11% <0.00%> (ø)
...rbosch/detekt/rules/style/EqualsOnSignatureLine.kt 72.72% <0.00%> (ø)
...t/core/reporting/console/AbstractFindingsReport.kt 100.00% <0.00%> (ø)
...h/detekt/formatting/wrappers/SpacingAroundComma.kt 100.00% <0.00%> (ø)
...ekt/formatting/wrappers/TypeArgumentListSpacing.kt 100.00% <0.00%> (ø)
... and 492 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@BraisGabin
Copy link
Collaborator

And thanks for the refactor! This code looks way better now :)

@marschwar
Copy link
Contributor Author

Do we want this feature or should I open a PR with just the refactoring?

@BraisGabin
Copy link
Collaborator

LGTM

@cortinico cortinico added the notable changes Marker for notable changes in the changelog label Aug 8, 2022
@cortinico cortinico added this to the 1.22.0 milestone Aug 8, 2022
@BraisGabin BraisGabin merged commit 2645549 into detekt:main Aug 21, 2022
21 checks passed
@marschwar marschwar deleted the feat/check-exhaustiveness branch September 19, 2022 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core notable changes Marker for notable changes in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mode or task to ensure configuration file is exhaustive
3 participants