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

"Configuration file not found in directory where diktat is run" warning is printed multiple times #1548

Closed
orchestr7 opened this issue Nov 4, 2022 · 1 comment · Fixed by #1553 or #1555
Assignees
Labels
bug Something isn't working
Milestone

Comments

@orchestr7
Copy link
Member

For diktat running in console we print "Configuration file not found in directory where diktat is run" too many times, should be once. This issue can be duplicate.

Affects usability of a cli tool.

@orchestr7 orchestr7 added the bug Something isn't working label Nov 4, 2022
@0x6675636b796f75676974687562
Copy link
Member

From the RuleSetProvider documentation (0.47.x):

This method is going to be called once for each file (which means if any of the rules have state or
are not thread-safe - a new RuleSet must be created).

This method is marked for removal in KtLint 0.48 for reason below:

For each invocation of KtLint.lint and KtLint.format the RuleSet is retrieved. This results in new
instances of each Rule for each file being processed. As of that a Rule does not need to be thread-safe.

However, KtLint.format requires the Rule to be executed twice on o a file in case at least one violation
has been autocorrected. As the same Rule instance is reused for the second execution of the Rule, the state
of the Rule is shared. As of this Rule have to clear their internal state.

So now rules are expected to have a state, and a new Rule instance is created per a file checked.

0x6675636b796f75676974687562 added a commit that referenced this issue Nov 7, 2022
### What's done:

 - Fixes #1548.
 - Since Diktat rules have no mutable state, it's safe to reuse them for
   checking multiple files.
@0x6675636b796f75676974687562 0x6675636b796f75676974687562 added this to the 1.2.4 milestone Nov 7, 2022
0x6675636b796f75676974687562 added a commit that referenced this issue Nov 7, 2022
### What's done:

 - Fixes #1548.
 - Since Diktat rules have no mutable state, it's safe to reuse them for
   checking multiple files.
0x6675636b796f75676974687562 added a commit that referenced this issue Nov 9, 2022
### What's done:

 - Original issue: #1548.
 - Original PR: #1553.
 - This change reverts 3470888.
 - Enhances the KDoc of `DiktatRule`.
 - Fixes #1548.
0x6675636b796f75676974687562 added a commit that referenced this issue Nov 9, 2022
### What's done:

 - Original issue: #1548.
 - Original PR: #1553.
 - This change reverts 3470888.
 - Enhances the KDoc of `DiktatRule`.
 - Fixes #1548.
0x6675636b796f75676974687562 added a commit that referenced this issue Nov 9, 2022
### What's done:

 - Original issue: #1548.
 - Original PR: #1553.
 - This change reverts 3470888.
 - Enhances the KDoc of `DiktatRule`.
 - Fixes #1548.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants