checkstyle / checkstyle/checkstyle

Move violation comments above of annotated methods

Open
#19,803 32 comments 0 reactions 0 assignees View on GitHub
approved good second issue miscellaneous
Dominant language
Java
Stars
9.6k
Forks
4.2k
Avg merge
22h 23m
Merged PRs (30d)
232

Description

Follow-up of https://github.com/checkstyle/checkstyle/issues/19757

Background
---
Find a way to fail build on cases of `//violation ....` usage in between of method javadoc java annotations and method signatures
We should keep target code as natural as possible to not let violation comment to do side effect to violation and let users recognize problems as in real code and comment around just hint on what is wrong.

bad
```
/**
* This Javadoc contains unclosed tag.
* unclosed 'code' tag
*/
// violation 2 lines above 'Unclosed HTML tag found: '
void foo() {}
```

good:
```
// violation 3 lines below 'Unclosed HTML tag found: '
/**
* This Javadoc contains unclosed tag.
* unclosed 'code' tag
*/
void foo() {}
```

--------

bad
```
@Override
// violation above 'xxx'
void foo() {}
```

good:
```
// violation below 'xxx'
@Override
void foo() {}
```

Task
---
Ensure no violation comments in between of methods signature and annoation or javadoc all existing input files.

Here is a list of existing input files to be fixed:
https://github.com/checkstyle/checkstyle/blob/876d99c33fc5af08b88a88db768dc7e40b351384/config/checkstyle-input-suppressions.xml#L143-L147

How to contribute
---
1. Choose a Check (group of Inputs for same Check) from the list;
2. Move all violation out of target code snippets;
3. Remove related suppressions;
4. Update violation line numbers inside unit test methods, if any changed.
5. Send PR.

Notes
---
1. Moving violating comments around requires adding `(X lines) above/below` to make sure they still reference the same line. You can refer to [guide to specify violations](https://github.com/checkstyle/checkstyle/blob/master/docs/specifying-violations.md) for syntax.
2. Make sure no input files exceed the limit of 120 lines.

Example of expected update https://github.com/checkstyle/checkstyle/pull/19804/changes , https://github.com/checkstyle/checkstyle/pull/19811

Contributor guide

Open the contributing guide

Research direction

Start with the existing input-file list in config/checkstyle-input-suppressions.xml around lines 143-147, then choose one Check and inspect its related test inputs and unit test methods. Move violation comments outside method Javadocs and annotations, remove related suppressions, and update any changed violation line numbers. Verify the inputs stay within 120 lines and run the relevant unit tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.