checkstyle / checkstyle

Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Google Java Style Guide and Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.
https://checkstyle.org
GNU Lesser General Public License v2.1
8.28k stars 3.65k forks source link

Remove '//ok' comments from Input files #13213

Open romani opened 1 year ago

romani commented 1 year ago

After hundreds of example PR reviews, I , and not only I found that comment ok is just a noise that makes it hard to read. This example is small, so you will not fill pain, but, there are more complicated examples and it is not good. I agree to put comment to explain some not obvious reason, but it will be exception.

For now I treat all //ok comments as stuff to remove, there might be cases to keep them as form of: // ok, here is not obvious reason // ok, here is pointing to Check limitation In short - when it is not obvious.

all suppression <suppress id="UnnecessaryOkComment" for at https://github.com/checkstyle/checkstyle/blob/master/config/checkstyle-input-suppressions.xml should be removed and referenced files updated to not have "// ok" comments

We do need this removals in test inputs. Same is for Example files, it just makes example full of content that is hard to distinguish without code coloring.

user should see is comment as red flag of attention. All other lines are without attention, as no violation on them, on all of them.

We use to have such comments only at times when we had no enforcing and it was very manual markers , but it lost its role after we finished Input based tests

Such ok comment become to appear in completely unrelated places, by copy paste, and keep it at right place is not possible( or hard and outside of this project). Better without it . Location of violation comment is enforced by runtime - never outdated.

Please choose name of module from file: https://github.com/checkstyle/checkstyle/blob/b6301c189ef5d2d731a755fa9a2e84aa0677494a/config/checkstyle-input-suppressions.xml#L68-L70 where name of module is equalsavoidnull and send PR for all files that belong to it in single PR.

final goal is to remove all suppressions of "UnnecessaryOkComment".

Example of update: https://github.com/checkstyle/checkstyle/pull/13609/files attention on removal of suppression See more examples below for "Merged" Pull Requests.


One more example of expected update: https://github.com/checkstyle/checkstyle/commit/f7927735cc28b62d7b40e46a944c7d495a531f68

romani commented 1 year ago

@Vyom-Yadav , @Kevin222004 , @rdiachenko , @nrmancuso , please share your opinion on this issue.

nrmancuso commented 1 year ago

Agree 100%, I think overuse of comments diminishes the concision of examples and inputs.

Vyom-Yadav commented 1 year ago

Agreed, let's only permit // violation and // ok, because of ........

Kevin222004 commented 1 year ago

I also agree to remove // ok.

rdiachenko commented 1 year ago

user should see is comment as red flag of attention. All other lines are without attention, as no violation on them, on all of them.

+1

romani commented 1 year ago

@stoyanK7 , please share your position on this

stoyanK7 commented 1 year ago

I also agree with removing // ok

romani commented 1 year ago

@rnveach , please share your thoughts

romani commented 1 year ago

@sheetalj2205, we are ready to start removal. Referenced PR is merged.

sheetalj2205 commented 1 year ago

@sheetalj2205, we are ready to start removal. Referenced PR is merged.

Okay, I am on it.

sheetalj2205 commented 1 year ago

Hello @romani I just want to check before moving forward whether I understood it correctly or not, as we can see in these files InputDefaultComesLastDefaultMethodsInInterface.java and illegaltype/InputIllegalTypeEmptyStringMemberModifiers.java there are multiple //ok comments, we need to remove that and put it only at one place that is after class or interface name and I am supposed to do that for all the files of com.puppycrawl.tools.checkstyle.checks.coding package.

romani commented 1 year ago

We need to remove all //ok comments and keep only comments that some text after it like //ok bla bla bla

sheetalj2205 commented 1 year ago

We need to remove all //ok comments and keep only comments that some text after it like //ok bla bla bla

can you please assign this to me

nrmancuso commented 1 year ago

@sheetalj2205 we do not assign issues except to maintainers, just make a comment like “I am on XXXCheck” and send a PR.

romani commented 1 year ago

@sheetalj2205, just make comment "I am xxxxxCheck tests" and send PR for single Check only. After we merge first PR you can send PRs for more, by group. We do not allow huge PRs that change all, such PRs usually never come to merge state.

nrmancuso commented 1 year ago

I am on MethodParamPadCheck

suniti0804 commented 10 months ago

I am on covariantequals

suniti0804 commented 10 months ago

I am on defaultcomeslast

dontwike commented 9 months ago

Please can you assign this issue.

romani commented 9 months ago

No assignments, just make a comment what check/module you are going to work and keep sending PRs. Thanks a lot for helping.

dontwike commented 9 months ago

Okay

harshit4311 commented 9 months ago

I would like to work on this issue!

romani commented 8 months ago

Just start sending PRs.

Zopsss commented 8 months ago

I'm on InputNoEnumTrailingComma

TarunAlapati-git commented 8 months ago

I am on missing switchdefault

mahfouz72 commented 8 months ago

Iam on unusedlocalvariable

SinghaAnirban005 commented 8 months ago

I am on operatorwrap

SinghaAnirban005 commented 8 months ago

I am on InputNoFinalizerFallThroughJava

Ishantgarg-web commented 8 months ago

I am on InputOuterTypeFilename2

SinghaAnirban005 commented 8 months ago

I am on separatorwrap

FloofCat commented 8 months ago

I'm on InputEmptyCatchBlockViolationsByComment

anishlukk123 commented 7 months ago

im on InputOuterTypeFilename2.java without cr from Ishantgarg-web

MANISH-K-07 commented 7 months ago

Hey! I am on equalsavoidnull.

MANISH-K-07 commented 7 months ago

I am on InputOuterTypeFilename.

MANISH-K-07 commented 7 months ago

I am on 'illegaltype'

RatikaDogra commented 7 months ago

Hii.. I want to solve this issue please assign me

romani commented 7 months ago

No assignments, just make a comment what Test you updating and send PR.

Anirban6756 commented 7 months ago

Remove '//ok' comments from the input files

MANISH-K-07 commented 7 months ago

I am working on requirethis.

sktpy commented 7 months ago

I am on SuppressWarningsCheck

RatikaDogra commented 7 months ago

Remove '//ok' comments from the input files

ankitshokeen commented 7 months ago

removed '// ok' comments from input files #14325 https://github.com/checkstyle/checkstyle/pull/14325/files

RatikaDogra commented 7 months ago

Removing //ok from abbreviationaswordinname under naming directory

ViswanathBalla22 commented 7 months ago

hi @romani @nrmancuso I want to write the code that user will not able to write only\ok comment this helps us to next time we not get new ok comment my aproach for this is create java file name as CustomOkcomment check that extends AbstarctCheck ,this code for user to avoid using simple //ok comments and they need to provide more context or remove if unnecessary. and the custom check to checksyle.xml, create a new module

romani commented 7 months ago

I want to write the code that user will not able to write only\ok comment this helps us to next time we not get new ok comment

We already have this validation, in this issue we just resolving old problems, that is why removal of suppression lines is required in each update

ratatall commented 6 months ago

Hey! Just wanted to notify you that I'm working on InputUnnecessaryParenthesesIfStatement2 to remove all ok comments.

555vedant commented 6 months ago

@romani sir , as you mentioned in above issue , we have to remove this from each individual files ?

MANISH-K-07 commented 6 months ago

@romani sir , as you mentioned in above issue , we have to remove this from each individual files ?

@555vedant Pick a module, comment "I am on xxx" and remove all related suppressions. It is recommended to limit your PR to single module

HRuii1 commented 6 months ago

Hi I'm on InputRequireThisTryWithResources

abhishekmaity commented 6 months ago

I am on InputRequireThisTryWithResourcesOnlyOverlappingFalse