-
Notifications
You must be signed in to change notification settings - Fork 507
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
Drop support for ktlint-enable / ktlint-disable directive #1947
Comments
Using Github Code Search some insight can be collected in how the old directives are used. Unfortunately, the total number of search result is currently limited to 100 results. By excluding based on repository, some more insights can be collected but this is also limited. In summer 2023 a new search API is expected which should be able to return all search results. Insights sofar: If a single construct is surrounded by a block directive, it should be replaced by an annotation on that single construct:
However if the directive block contains multiple statements, it can not be simply replaced with a Suppress on the first (nor on all statements). Moving the Suppress to an outer construct is not always equivalent to current situation:
In example below, the block directive should be replaced with a file-annotation or the annotation must be interpreted as being relevant for the entire import list (but what if the annotation is not placed just before the first import?):
In case below, the same EOL directive is repeated multiple times, but not on all lines. Usage of the block directive would have been a better choice in this example. But this is similar to one of problems mentioned before:
References to old
In example below, the block directive should be replace with a file annotation:
|
or @SuppressWarnings annotations Note that the SuppressionLocatorBuilder never ignore this rule as otherwise the suppression hint to ignore *all* rules would also ignore the rule which has to migrate this suppression hint. Closes #1947
* Add rule to migrate ktlint-disable directives from comments to @Suppress or @SuppressWarnings annotations Note that the SuppressionLocatorBuilder never ignore this rule as otherwise the suppression hint to ignore *all* rules would also ignore the rule which has to migrate this suppression hint. Closes #1947 * Fix max line length for markdown files * Fix wildcard imports settings * Improve trace logging by printing a lint error directly when it is emitted The reports print the lint violations in which they occur in the source code. This is not necessarily the order in which they are detected and fixed. For debugging some type of problems, the latter order is important. * Add "libs.logback" as runtime only dependency so that logging is visible in unit tests
The directives below can be used to suppress ktlint rules:
The usage of
Suppress
andSuppressWarning
annotation however is more native and should be the only way starting from1.0
version:Ideally, a rule is added which helps in autocorrecting the old directives to annotations. If this is implemented, take care that this rule itself should not be suppressed even in case for a line, block or file all annotations are suppressed.
The text was updated successfully, but these errors were encountered: