You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/02/27 09:06:35 UTC
[maven-checkstyle-plugin] 01/02: make violation immuatble and
non-public
This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch MCHECKSTYLE-385
in repository https://gitbox.apache.org/repos/asf/maven-checkstyle-plugin.git
commit 1762639678601b0898a5869ba8ac27a3b77dd780
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Thu Feb 27 10:05:13 2020 +0100
make violation immuatble and non-public
---
.../checkstyle/CheckstyleViolationCheckMojo.java | 9 ++++---
.../apache/maven/plugins/checkstyle/Violation.java | 30 ++++++----------------
2 files changed, 13 insertions(+), 26 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 803e948..bfcd220 100644
--- a/src/main/java/org/apache/maven/plugins/checkstyle/Violation.java
+++ b/src/main/java/org/apache/maven/plugins/checkstyle/Violation.java
@@ -72,16 +72,18 @@ class Violation
* the category of the checkstyle violation
*/
Violation( String source,
- String file,
- String line,
- String severity,
- String message,
- String ruleName,
- String category )
+ 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 @@ 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