Skip to content

Commit

Permalink
Issue #12241: removes package private constructors and pmd association
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and romani committed Oct 5, 2022
1 parent a78224b commit 70bbcd8
Show file tree
Hide file tree
Showing 44 changed files with 83 additions and 94 deletions.
Expand Up @@ -1689,7 +1689,7 @@
<fileName>checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheck.java</fileName>
<specifier>initialization.fields.uninitialized</specifier>
<message>the constructor does not initialize fields: frameName</message>
<lineContent>/* package */ FieldFrame(FieldFrame parent) {</lineContent>
<lineContent>private FieldFrame(FieldFrame parent) {</lineContent>
</checkerFrameworkError>

<checkerFrameworkError unstable="false">
Expand Down Expand Up @@ -2258,7 +2258,7 @@
<fileName>checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheck.java</fileName>
<specifier>initialization.fields.uninitialized</specifier>
<message>the constructor does not initialize fields: maxAllowed</message>
<lineContent>/* package */ Context(boolean checking) {</lineContent>
<lineContent>private Context(boolean checking) {</lineContent>
</checkerFrameworkError>

<checkerFrameworkError unstable="false">
Expand Down
12 changes: 0 additions & 12 deletions config/pmd.xml
Expand Up @@ -9,23 +9,11 @@
</description>

<rule ref="category/java/bestpractices.xml">
<!-- We do not care about this minor overhead, we are not Android application and we do not
want to change visibility of methods. Package-private visibility should be avoided almost
always. -->
<exclude name="AccessorMethodGeneration"/>
<!-- The PMD mistakes the AbstractViolationReporter::log() as a debug log. -->
<exclude name="GuardLogStatement"/>
<!-- too much false-positives from 6.18.0 -->
<exclude name="UnusedPrivateMethod"/>
</rule>
<rule ref="category/java/bestpractices.xml/AccessorClassGeneration">
<properties>
<!-- The PMD gives false positive for Builder patterns. Fixed in PMD 7. -->
<property name="violationSuppressXPath"
value="//ClassOrInterfaceDeclaration
[@SimpleName='TestInputConfiguration' or @SimpleName='ModuleInputConfiguration']"/>
</properties>
</rule>
<rule ref="category/java/bestpractices.xml/AvoidPrintStackTrace">
<properties>
<!-- It is ok to use print stack trace in CLI class. -->
Expand Down
Expand Up @@ -226,7 +226,7 @@ private static final class ViolationPosition {
* @param violationLineNumber line no of the violation produced for the check.
* @param violationColumnNumber column no of the violation produced for the check.
*/
/* package */ ViolationPosition(int violationLineNumber,
private ViolationPosition(int violationLineNumber,
int violationColumnNumber) {
this.violationLineNumber = violationLineNumber;
this.violationColumnNumber = violationColumnNumber;
Expand Down
Expand Up @@ -488,7 +488,7 @@ private final class InternalLoader
* @throws SAXException if an error occurs
* @throws ParserConfigurationException if an error occurs
*/
/* package */ InternalLoader()
private InternalLoader()
throws SAXException, ParserConfigurationException {
super(createIdToResourceNameMap());
}
Expand Down
Expand Up @@ -379,7 +379,7 @@ private boolean isResourceLocationInCache(String location) {
/**
* Class which represents external resource.
*/
private static class ExternalResource {
private static final class ExternalResource {

/** Location of resource. */
private final String location;
Expand All @@ -392,7 +392,7 @@ private static class ExternalResource {
* @param location resource location.
* @param contentHashSum content hash sum.
*/
/* package */ ExternalResource(String location, String contentHashSum) {
private ExternalResource(String location, String contentHashSum) {
this.location = location;
this.contentHashSum = contentHashSum;
}
Expand Down
Expand Up @@ -595,7 +595,7 @@ public void destroy() {
}

/** Records a particular suppression for a region of a file. */
private static class Entry {
private static final class Entry {

/** The source name of the suppressed check. */
private final String checkName;
Expand All @@ -617,7 +617,7 @@ private static class Entry {
* @param lastLine the last line of the suppression region
* @param lastColumn the last column of the suppression region
*/
/* package */ Entry(String checkName, int firstLine, int firstColumn,
private Entry(String checkName, int firstLine, int firstColumn,
int lastLine, int lastColumn) {
this.checkName = checkName;
this.firstLine = firstLine;
Expand Down
Expand Up @@ -640,7 +640,7 @@ private void logException(Exception exception, File file) {
}

/** Class which represents a resource bundle. */
private static class ResourceBundle {
private static final class ResourceBundle {

/** Bundle base name. */
private final String baseName;
Expand All @@ -658,7 +658,7 @@ private static class ResourceBundle {
* @param path common path of files which are included in the resource bundle.
* @param extension common extension of files which are included in the resource bundle.
*/
/* package */ ResourceBundle(String baseName, String path, String extension) {
private ResourceBundle(String baseName, String path, String extension) {
this.baseName = baseName;
this.path = path;
this.extension = extension;
Expand Down
Expand Up @@ -199,7 +199,7 @@ private boolean isOverridingMethod(DetailAST ast) {
* Stack node for a method definition and a record of
* whether the method has a call to the super method.
*/
private static class MethodNode {
private static final class MethodNode {

/** Method definition. */
private final DetailAST method;
Expand All @@ -212,7 +212,7 @@ private static class MethodNode {
*
* @param ast AST for the method definition.
*/
/* package */ MethodNode(DetailAST ast) {
private MethodNode(DetailAST ast) {
method = ast;
callingSuper = false;
}
Expand Down
Expand Up @@ -551,7 +551,7 @@ private static boolean astTypeIsClassOrEnumOrRecordDef(int tokenType) {
/**
* Holds the names of fields of a type.
*/
private static class FieldFrame {
private static final class FieldFrame {

/** Parent frame. */
private final FieldFrame parent;
Expand All @@ -576,7 +576,7 @@ private static class FieldFrame {
*
* @param parent parent frame.
*/
/* package */ FieldFrame(FieldFrame parent) {
private FieldFrame(FieldFrame parent) {
this.parent = parent;
}

Expand Down
Expand Up @@ -825,7 +825,7 @@ public Optional<FinalVariableCandidate> findFinalVariableCandidateForAst(DetailA
}

/** Represents information about final local variable candidate. */
private static class FinalVariableCandidate {
private static final class FinalVariableCandidate {

/** Identifier token. */
private final DetailAST variableIdent;
Expand All @@ -839,7 +839,7 @@ private static class FinalVariableCandidate {
*
* @param variableIdent variable identifier.
*/
/* package */ FinalVariableCandidate(DetailAST variableIdent) {
private FinalVariableCandidate(DetailAST variableIdent) {
this.variableIdent = variableIdent;
}

Expand Down
Expand Up @@ -781,7 +781,7 @@ public void setIgnoreAbstractMethods(
/**
* Holds the names of static and instance fields of a type.
*/
private static class FieldFrame {
private static final class FieldFrame {

/** Name of the frame, such name of the class or enum declaration. */
private final String frameName;
Expand All @@ -805,7 +805,7 @@ private static class FieldFrame {
* @param staticType is this a static inner type (class or enum).
* @param frameName name associated with the frame, which can be a
*/
/* package */ FieldFrame(FieldFrame parent, boolean staticType, String frameName) {
private FieldFrame(FieldFrame parent, boolean staticType, String frameName) {
this.parent = parent;
this.staticType = staticType;
this.frameName = frameName;
Expand Down
Expand Up @@ -1471,7 +1471,7 @@ private static class ClassFrame extends AbstractFrame {
* @param parent parent frame.
* @param ident frame name ident.
*/
/* package */ ClassFrame(AbstractFrame parent, DetailAST ident) {
private ClassFrame(AbstractFrame parent, DetailAST ident) {
super(parent, ident);
instanceMembers = new HashSet<>();
instanceMethods = new HashSet<>();
Expand Down
Expand Up @@ -456,7 +456,7 @@ private void visitReturn(DetailAST ast) {
/**
* Class to encapsulate information about one method.
*/
private class Context {
private final class Context {

/** Whether we should check this method or not. */
private final boolean checking;
Expand All @@ -472,7 +472,7 @@ private class Context {
*
* @param checking should we check this method or not
*/
/* package */ Context(boolean checking) {
private Context(boolean checking) {
this.checking = checking;
}

Expand Down
Expand Up @@ -874,7 +874,7 @@ private static final class VariableDesc {
* {@link TokenTypes#LITERAL_FOR} or {@link TokenTypes#OBJBLOCK}
* which is enclosing the variable
*/
/* package */ VariableDesc(String name, DetailAST typeAst, DetailAST scope) {
private VariableDesc(String name, DetailAST typeAst, DetailAST scope) {
this.name = name;
this.typeAst = typeAst;
this.scope = scope;
Expand Down Expand Up @@ -949,7 +949,7 @@ public boolean isInstVarOrClassVar() {
* or {@link TokenTypes#ENUM_DEF} or {@link TokenTypes#ANNOTATION_DEF}
* or {@link TokenTypes#RECORD_DEF} is considered as a type declaration.
*/
private static class TypeDeclDesc {
private static final class TypeDeclDesc {

/**
* Complete type declaration name with package name and outer type declaration name.
Expand Down Expand Up @@ -978,7 +978,7 @@ private static class TypeDeclDesc {
* @param depth depth of nesting
* @param typeDeclAst type declaration ast node
*/
/* package */ TypeDeclDesc(String qualifiedName, int depth,
private TypeDeclDesc(String qualifiedName, int depth,
DetailAST typeDeclAst) {
this.qualifiedName = qualifiedName;
this.depth = depth;
Expand Down
Expand Up @@ -459,7 +459,7 @@ private static class TypeDeclarationDescription {
* @param depth Depth of nesting of type declaration
* @param typeDeclarationAst Type declaration ast node
*/
/* package */ TypeDeclarationDescription(String qualifiedName, int depth,
private TypeDeclarationDescription(String qualifiedName, int depth,
DetailAST typeDeclarationAst) {
this.qualifiedName = qualifiedName;
this.depth = depth;
Expand Down Expand Up @@ -525,7 +525,7 @@ private static final class ClassDesc extends TypeDeclarationDescription {
* @param depth class nesting level
* @param classAst classAst node
*/
/* package */ ClassDesc(String qualifiedName, int depth, DetailAST classAst) {
private ClassDesc(String qualifiedName, int depth, DetailAST classAst) {
super(qualifiedName, depth, classAst);
final DetailAST modifiers = classAst.findFirstToken(TokenTypes.MODIFIERS);
declaredAsFinal = modifiers.findFirstToken(TokenTypes.FINAL) != null;
Expand Down
Expand Up @@ -185,7 +185,7 @@ private static boolean isStatic(DetailAST ast) {
/**
* Details of class that are required for validation.
*/
private static class Details {
private static final class Details {

/** Class ast. */
private final DetailAST ast;
Expand All @@ -203,7 +203,7 @@ private static class Details {
*
* @param ast class ast
* */
/* package */ Details(DetailAST ast) {
private Details(DetailAST ast) {
this.ast = ast;
}

Expand Down
Expand Up @@ -1279,7 +1279,7 @@ private static String getFirstDomainsFromIdent(
* Contains import attributes as line number, import full path, import
* group.
*/
private static class ImportDetails {
private static final class ImportDetails {

/** Import full path. */
private final String importFullPath;
Expand All @@ -1305,7 +1305,7 @@ private static class ImportDetails {
* @param importAST
* import ast
*/
/* package */ ImportDetails(String importFullPath, String importGroup, boolean staticImport,
private ImportDetails(String importFullPath, String importGroup, boolean staticImport,
DetailAST importAST) {
this.importFullPath = importFullPath;
this.importGroup = importGroup;
Expand Down Expand Up @@ -1377,7 +1377,7 @@ public DetailAST getImportAST() {
* Contains matching attributes assisting in definition of "best matching"
* group for import.
*/
private static class RuleMatchForImport {
private static final class RuleMatchForImport {

/** Position of matching string for current best match. */
private final int matchPosition;
Expand All @@ -1396,7 +1396,7 @@ private static class RuleMatchForImport {
* @param position
* Matching position.
*/
/* package */ RuleMatchForImport(String group, int length, int position) {
private RuleMatchForImport(String group, int length, int position) {
this.group = group;
matchLength = length;
matchPosition = position;
Expand Down
Expand Up @@ -1170,7 +1170,7 @@ public final Token getName() {
/**
* Represents text element with location in the text.
*/
private static class Token {
private static final class Token {

/** Token's column number. */
private final int columnNo;
Expand All @@ -1186,7 +1186,7 @@ private static class Token {
* @param lineNo token's line number
* @param columnNo token's column number
*/
/* package */ Token(String text, int lineNo, int columnNo) {
private Token(String text, int lineNo, int columnNo) {
this.text = text;
this.lineNo = lineNo;
this.columnNo = columnNo;
Expand All @@ -1197,7 +1197,7 @@ private static class Token {
*
* @param fullIdent full ident to convert.
*/
/* package */ Token(FullIdent fullIdent) {
private Token(FullIdent fullIdent) {
text = fullIdent.getText();
lineNo = fullIdent.getLineNo();
columnNo = fullIdent.getColumnNo();
Expand All @@ -1221,7 +1221,7 @@ public String toString() {
}

/** Stores useful information about declared exception. */
private static class ExceptionInfo {
private static final class ExceptionInfo {

/** AST node representing this exception. */
private final DetailAST ast;
Expand All @@ -1237,7 +1237,7 @@ private static class ExceptionInfo {
* @param ast AST node representing this exception
* @param classInfo class info
*/
/* package */ ExceptionInfo(DetailAST ast, ClassInfo classInfo) {
private ExceptionInfo(DetailAST ast, ClassInfo classInfo) {
this.ast = ast;
this.classInfo = classInfo;
}
Expand Down
Expand Up @@ -282,7 +282,7 @@ private static final class Point {
* @param lineNo line number
* @param columnNo column number
*/
/* package */ Point(int lineNo, int columnNo) {
private Point(int lineNo, int columnNo) {
this.lineNo = lineNo;
this.columnNo = columnNo;
}
Expand Down
Expand Up @@ -328,7 +328,7 @@ private void visitAnnotationType(DetailAST annotationAST) {
* Encapsulates information about class coupling.
*
*/
private class ClassContext {
private final class ClassContext {

/**
* Set of referenced classes.
Expand All @@ -347,7 +347,7 @@ private class ClassContext {
* @param className name of the given class.
* @param ast ast of class definition.
*/
/* package */ ClassContext(String className, DetailAST ast) {
private ClassContext(String className, DetailAST ast) {
this.className = className;
classAst = ast;
}
Expand Down

0 comments on commit 70bbcd8

Please sign in to comment.