You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2020/01/04 15:15:08 UTC

[maven-checkstyle-plugin] 01/01: make violation immuatble and non-public

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch pr/17
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git

commit f68892d5c15f048956b874bc64ad325ec8ffd894
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Sat Jan 4 10:14:46 2020 -0500

    make violation immuatble and non-public
---
 .../checkstyle/CheckstyleViolationCheckMojo.java   |  9 +++---
 .../apache/maven/plugins/checkstyle/Violation.java | 34 +++++++---------------
 2 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
index 9bbd30b..4b0ea1d 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java
@@ -653,6 +653,10 @@ public class CheckstyleViolationCheckMojo
             String line = xpp.getAttributeValue( "", "line" );
             /* Nullable */
             String column = xpp.getAttributeValue( "", "column" );
+            if ( column == null )
+            {
+                column = Violation.NO_COLUMN;
+            }
             String message = xpp.getAttributeValue( "", "message" );
             String rule = RuleUtil.getName( source );
             String category = RuleUtil.getCategory( source );
@@ -661,15 +665,12 @@ public class CheckstyleViolationCheckMojo
                 source,
                 file,
                 line,
+                column,
                 severity,
                 message,
                 rule,
                 category
             );
-            if ( column != null )
-            {
-                violation.setColumn( column );
-            }
 
             violations.add( violation );
         }
diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/Violation.java b/src/main/java/org/apache/maven/plugins/checkstyle/Violation.java
index 82d71fa..bfcd220 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/Violation.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/Violation.java
@@ -25,7 +25,7 @@ import java.util.StringJoiner;
 /**
  * Holds data about a single violation and represents the violation itself.
  */
-public class Violation
+class Violation
 {
 
   /**
@@ -71,17 +71,19 @@ public class Violation
    * @param category
    *     the category of the checkstyle violation
    */
-  public Violation( String source,
-                    String file,
-                    String line,
-                    String severity,
-                    String message,
-                    String ruleName,
-                    String category )
+  Violation( String source,
+             String file,
+             String line,
+             String column,
+             String severity,
+             String message,
+             String ruleName,
+             String category )
   {
     this.source = Objects.requireNonNull( source );
     this.file = file;
     this.line = line;
+    this.column = column;
     this.severity = Objects.requireNonNull( severity );
     this.message = Objects.requireNonNull( message );
     this.ruleName = Objects.requireNonNull( ruleName );
@@ -129,22 +131,6 @@ public class Violation
   }
 
   /**
-   * Sets the column value for this violation to the given string value.
-   * @param column the column value to set. May be {@code null}, which will set it to the {@link #NO_COLUMN} value.
-   */
-  protected void setColumn( /* Nullable */ String column )
-  {
-    if ( column == null || column.length() < 1 )
-    {
-      this.column = NO_COLUMN;
-    }
-    else
-    {
-      this.column = column;
-    }
-  }
-
-  /**
    * Returns the severity of the current violation.
    *
    * @return the severity of the current violation