Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add file annotations rule #714

Merged
merged 3 commits into from
May 26, 2020
Merged

Add file annotations rule #714

merged 3 commits into from
May 26, 2020

Conversation

t-kameyama
Copy link
Contributor

Fixes #689

@t-kameyama t-kameyama force-pushed the issue_689 branch 2 times, most recently from 764119a to 797749d Compare March 12, 2020 10:02
@t-kameyama t-kameyama force-pushed the issue_689 branch 4 times, most recently from b1b8560 to 33b22a2 Compare May 13, 2020 10:15
@@ -30,6 +37,7 @@ class AnnotationRule : Rule("annotation") {
"Multiple annotations should not be placed on the same line as the annotated construct"
const val annotationsWithParametersAreNotOnSeparateLinesErrorMessage =
"Annotations with parameters should all be placed on separate lines prior to the annotated construct"
const val fileAnnotationsShouldBeSeparated = "File annotations should be separated from packages with a blank line"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Following up from #747, I think the wording should be a bit different, cause there's not necessarily a package coming after a file annotation (e.g. in .kts files). So maybe change it to from file contents or something like that.

if (lineNumber != null && nextLineNumber != null) {
val diff = nextLineNumber - lineNumber
if (diff < 2) {
emit(0, fileAnnotationsShouldBeSeparated, true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, what if there's a license header above the file annotation, then I guess 0 offset is not correct anymore? According to codestyle, there can be something on top of the annotation.

@t-kameyama t-kameyama requested a review from romtsn May 26, 2020 08:14
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format file annotations
3 participants