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

Enforce file size on Java inputs #11163

Open
romani opened this issue Jan 7, 2022 · 45 comments · Fixed by #11177
Open

Enforce file size on Java inputs #11163

romani opened this issue Jan 7, 2022 · 45 comments · Fixed by #11177

Comments

@romani
Copy link
Member

romani commented Jan 7, 2022

From #11156 (review)

All suppressions can be resolved in separate PRs for each Check individually.

Rationale: big input files a hard to review, hard to debug.

All existing inputs are moved to suppression at 3b523bd

<!-- Until https://github.com/checkstyle/checkstyle/issues/11163 -->

Now we need to update all that inputs to follow limit 120 and remove related suppressions. Each Check inputs should be in separate Pull Request

Example of update: 8673001

Test method names and input file name should be similar and describe what we are testing. Example from link above:

  • Test method name is testJavadocVariableOnInnerClassFields
  • Input file name is InputJavadocVariableOnInnerClassFields.java

List of checks for which we need to enforce file size on inputs -

  • AbbreviationAsWordInName
  • AnnotationLocation
  • Antlr4AstRegression
  • Antlr4AstRegressionUncommon
  • AnonInnerLength
  • AvoidEscapedUnicodeCharacters
  • CatchParameterName
  • ClassFanOutComplexity
  • CommentsIndentation
  • ConstantName
  • CorrectSummaryJavaDocCheck
  • CovariantEquals
  • CyclomaticComplexity
  • DefaultComesLast
  • DeclarationOrder
  • DesignForExtension
  • EmptyBlock
  • EmptyCatchBlock
  • EmptyLineSeparator
  • EqualsAvoidNull
  • EqualsHashCode
  • FallThrough
  • FileLength
  • FileTabCharacter
  • FinalClass
  • FinalLocalVariable
  • FinalParameters
  • HiddenField
  • IllegalInstantiation
  • IllegalTokenText
  • Indentation
  • IndentationCorrectIfAndParameter
  • InnerAssignment
  • Java14InstanceofWithPatternMatching
  • Java14Records
  • Java14SwitchExpression
  • Java14TextBlocks
  • JavaDocTagContinuationIndentation
  • JavaNCSS
  • JavaParserFullJavaIdentifierSupport
  • JavadocMethod
  • JavadocMetadataScraper
  • JavadocPackage
  • JavadocTagContinuationIndentation
  • JavadocType
  • JavadocVariable
  • LeftCurly
  • LineLength
  • LocalFinalVariableName
  • LocalVariableName
  • MainComplexityOverflow
  • MemberName
  • MethodCount
  • MethodLength
  • MethodName
  • MissingJavadocMethod
  • MissingJavadocType
  • ModifierOrder
  • MultipleStringLiterals
  • NPathComplexity
  • NeedBraces
  • NoEnumTrailingComma
  • NoFinalizer
  • NoWhitespaceAfter
  • NoWhitespaceBefore
  • OneStatementPerLine
  • OuterTypeNumber
  • PackageName
  • ParenPad
  • ParameterName
  • ParameterNumber
  • RecordComponentNumber
  • RedundantModifier
  • Regexp
  • RegexpMultiline
  • RegexpOnFilename
  • RegexpSingleline
  • RegexpSinglelineJava
  • RequireThis
  • RightCurly
  • Rule332NoLineWrap
  • Rule3SourceFile
  • Rule412NonEmptyBlocks
  • Rule42BlockIndentation
  • Rule44ColumnLimit
  • Rule451WhereToBreak
  • Rule452IndentContinuationLines
  • Rule461VerticalWhitespace
  • Rule462HorizontalWhitespace
  • Rule4641Indentation
  • Rule487Modifiers
  • Rule525NonConstantFieldNames
  • Rule64Finalizers
  • StaticVariableName
  • SummaryJavadoc
  • SuppressionCommentFilter
  • TodoComment
  • TypecastParenPad
  • UpperEll
  • VariableDeclarationUsageDistance
  • VisibilityModifier
  • WhitespaceAfter
  • WhitespaceAround
  • XpathMapperStringConcat
@romani romani added the approved label Jan 7, 2022
@Vyom-Yadav
Copy link
Member

Vyom-Yadav commented Jan 7, 2022

@romani Here is some data-

Total Num Of Lines: 226357
Total Num Of Files: 1976
Median of number of lines: 44.0
The average number of lines: 114.55313765182186

This includes Input files from both ../resources and ../resources-noncompilable.
How I generated the data: https://gist.github.com/Vyom-Yadav/76cedd6a5286496e25cf762b31ac2e10

Edit-
Not to forget we have a file with 65553 lines https://github.com/checkstyle/checkstyle/blob/master/src/test/resources/com/puppycrawl/tools/checkstyle/checks/avoidescapedunicodecharacters/InputAvoidEscapedUnicodeCharactersAllEscapedUnicodeCharacters.java and many more files which are used for testing stack overflow errors, etc.
I will send a fix once we decide the bottleneck on the number of lines an Input file can have.

@romani
Copy link
Member Author

romani commented Jan 8, 2022

I am ok to make max limit as 120 lines, I glanced through files, all big files are NOT for good reason.

@pbludov , @rnveach , @nmancus1 , @strkkk , please confirm that you are ok with this.
there definetely might be exceptions, and we can keep them as big files.

@rnveach
Copy link
Member

rnveach commented Jan 8, 2022

I would prefer a round number like 200.

Configuration javadoc, package, imports, class definitions, and the necessary blank lines add up.

@romani
Copy link
Member Author

romani commented Jan 9, 2022

We do not use imports that much, header comment is not that big. Please show me input file that is good to be above 120 lines. There might few only.

@pbludov
Copy link
Member

pbludov commented Jan 9, 2022

Long files list: https://gist.github.com/pbludov/fe3786436e177939e2041e3596626296
355 files > 120 lines
200 files > 200 lines

We can start with a limit of 200 lines, and then reduce the limit to 120.

@romani
Copy link
Member Author

romani commented Jan 9, 2022

count of files is not that I worry about. This task will be perfect for introduction to project, so it will be long lasting and done eventually - ok.

Having two iterations: to 200 and then to 120 will be a lot of efforts. Contributor will spend same time to split files from xxxxx to 200 as to xxxx to 120.

@nrmancuso
Copy link
Member

I am ok to make max limit as 120 lines...

I agree that this is a good limit under normal circumstances. Limiting file lengths will help to make violations more clear, and to reduce/ eliminate extension of existing test inputs.

In PR for this issue, we should decide on big files to keep with comment explaining why for each suppression, then have contributors simply select suppression with no comment to work on.

@romani
Copy link
Member Author

romani commented Jan 10, 2022

First PR should do suppression "until #11163". If we decide to keep big input, we should make special comment.

@strkkk
Copy link
Member

strkkk commented Jan 10, 2022

I am ok with 120

@Vyom-Yadav
Copy link
Member

Here is some more data to help you decide whether it will be 120 or 200.

Total Num Of Lines: 54466
The average number of lines: 27.521980798383023

This number is composed of the following-

/*
SomeCheck
max = (default)200


*/

package com......

public class InputSomeCheck {

    void method() {
    }

}

Total num of lines before top-level class declaration - 10 (includes the class declaration)
Total num of empty lines (for readability of code) - 2 (After class declaration)
Total = 10 + 2 = 12
Here is the data for every input file (.java) - https://gist.github.com/Vyom-Yadav/44af5b511fd2d7b89eacacb62fed7ea5

@romani
Copy link
Member Author

romani commented Jan 10, 2022

We come to majority agreement to make it 120.

We can always keep in permanent suppression cases that need more for good reason or we can make limit higher later on.
For now let's try 120.

@Vyom-Yadav , can you send PR that will do validation and placing all files above limit to temporary suppression ?

Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 11, 2022
@rnveach rnveach changed the title Enforce file size on inputs Enforce file size on Java inputs Jan 11, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 12, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 12, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 12, 2022
Vyom-Yadav added a commit to Vyom-Yadav/checkstyle that referenced this issue Jan 12, 2022
MANISH-K-07 added a commit to MANISH-K-07/checkstyle that referenced this issue Jan 29, 2024
MANISH-K-07 added a commit to MANISH-K-07/checkstyle that referenced this issue Jan 29, 2024
@github-actions github-actions bot modified the milestones: 10.13.0, 10.13.1 Jan 30, 2024
MANISH-K-07 added a commit to MANISH-K-07/checkstyle that referenced this issue Jan 30, 2024
romani pushed a commit to mahfouz72/checkstyle that referenced this issue Jan 30, 2024
@Vyom-Yadav

This comment was marked as outdated.

@MANISH-K-07

This comment was marked as resolved.

@Vyom-Yadav

This comment was marked as outdated.

@MANISH-K-07

This comment was marked as resolved.

mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 6, 2024
@nrmancuso
Copy link
Member

@MANISH-K-07 @Vyom-Yadav now that we have opened an issue on input file/test method naming conventions, please mark your comments as outdated to clean this issue up.

mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 7, 2024
mahfouz72 added a commit to mahfouz72/checkstyle that referenced this issue Feb 7, 2024
piyush-1234 pushed a commit to piyush-1234/checkstyle that referenced this issue Feb 9, 2024
Coding-Aliens pushed a commit to Coding-Aliens/checkstyle that referenced this issue Feb 23, 2024
Bumps [com.google.truth:truth](https://github.com/google/truth) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/google/truth/releases)
- [Commits](google/truth@v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: com.google.truth:truth
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Issue checkstyle#6207: Enale XpathRegressionTest for IlegalTokenText

dependency: bump org.pitest:pitest-maven from 1.15.3 to 1.15.4

Bumps [org.pitest:pitest-maven](https://github.com/hcoles/pitest) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/hcoles/pitest/releases)
- [Commits](hcoles/pitest@1.15.3...1.15.4)

---
updated-dependencies:
- dependency-name: org.pitest:pitest-maven
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Issue checkstyle#13213: removed //ok metrics,design

Issue checkstyle#13213: Removed //ok from leftout files

Issue checkstyle#13999: Resolve pitest suppression for throwAst.getParent() of JavadocMethod

Issue checkstyle#13213: Removed //ok noncompilable/naming

dependency: bump org.pitest:pitest-maven from 1.15.4 to 1.15.6

Bumps [org.pitest:pitest-maven](https://github.com/hcoles/pitest) from 1.15.4 to 1.15.6.
- [Release notes](https://github.com/hcoles/pitest/releases)
- [Commits](hcoles/pitest@1.15.4...1.15.6)

---
updated-dependencies:
- dependency-name: org.pitest:pitest-maven
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Issue checkstyle#11163: Enforced file size inputs

Issue checkstyle#6207: Add XPath IT Regression test for CatchParameterName

Issue checkstyle#11163: Enforced filesize commentsindentation

Issue checkstyle#13213: removed //ok noncompilable/sizes

Issue checkstyle#13213: Removed //ok from methodcount

Issue checkstyle#11163: enforced filesize MissingJavadocTypeTags

Issue checkstyle#6207: Enable XpathRegressiontest for EqualsHashCode

Issue checkstyle#13213: Removed //ok from nolinewrap

Issue checkstyle#13213: Removed //ok from declarationorder

Issue checkstyle#14137: Enable `MockitoStubbing` check

Issue checkstyle#13213: removed //ok noncompilable/whitespace

Issue checkstyle#13345: Enable StaticVariableNameCheckExamplesTest

Issue checkstyle#14137: Enable `TimeZoneUsage` check

Issue checkstyle#11163: Enforced filesize TypeNoJavadoc1

doc: release notes for 10.13.0

[maven-release-plugin] prepare release checkstyle-10.13.0

[maven-release-plugin] prepare for next development iteration

doc: fix releasenotes.xml line length violation

Issue# 13999: RemoveConditionalMutator_EQUAL_IF on if (child.getType() == TokenTypes.PARAMETER_DEF)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.