10: Add description model to issues
This commit is contained in:
@@ -23,7 +23,8 @@ dependencies {
|
||||
compile "com.github.javaparser:javaparser-core:${javaParserVersion}"
|
||||
compile "commons-io:commons-io:${commonsIoVersion}"
|
||||
compile "org.fusesource.jansi:jansi:${jansiVersion}"
|
||||
|
||||
compile "org.apache.commons:commons-lang3:${commonsLangVersion}"
|
||||
compile "org.apache.commons:commons-text:${commonsTextVersion}"
|
||||
}
|
||||
|
||||
jar {
|
||||
|
||||
@@ -6,4 +6,6 @@ ext {
|
||||
javaParserVersion = '3.13.4'
|
||||
commonsIoVersion = '2.6'
|
||||
jansiVersion = '1.17.1'
|
||||
commonsLangVersion = '3.8.1'
|
||||
commonsTextVersion = '1.6'
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import com.bartek.esa.core.model.object.Issue;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class BasePlugin implements Plugin {
|
||||
@@ -32,11 +34,21 @@ public abstract class BasePlugin implements Plugin {
|
||||
addIssue(severity, "", lineNumber, line);
|
||||
}
|
||||
|
||||
protected void addIssue(Severity severity, Map<String, String> descriptionModel, Integer lineNumber, String line) {
|
||||
addIssue(severity, "", descriptionModel, lineNumber, line);
|
||||
}
|
||||
|
||||
|
||||
protected void addIssue(Severity severity, String descriptionCode, Integer lineNumber, String line) {
|
||||
addIssue(severity, descriptionCode, new HashMap<>(), lineNumber, line);
|
||||
}
|
||||
|
||||
protected void addIssue(Severity severity, String descriptionCode, Map<String, String> descriptionModel, Integer lineNumber, String line) {
|
||||
Issue issue = Issue.builder()
|
||||
.severity(severity)
|
||||
.issuer(this.getClass())
|
||||
.descriptionCode(descriptionCode)
|
||||
.descriptionModel(descriptionModel)
|
||||
.file(file)
|
||||
.lineNumber(lineNumber)
|
||||
.line(line)
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.w3c.dom.Node;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class JavaPlugin extends BasePlugin {
|
||||
private final GlobMatcher globMatcher;
|
||||
@@ -47,6 +48,7 @@ public abstract class JavaPlugin extends BasePlugin {
|
||||
Issue issue = Issue.builder()
|
||||
.issuer(JavaPlugin.class)
|
||||
.descriptionCode(".NO_PACKAGE")
|
||||
.descriptionModel(new HashMap<>())
|
||||
.severity(Severity.ERROR)
|
||||
.build();
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bartek.esa.core.desc.provider;
|
||||
import com.bartek.esa.core.model.object.Issue;
|
||||
import com.bartek.esa.error.EsaException;
|
||||
import io.vavr.control.Try;
|
||||
import org.apache.commons.text.StringSubstitutor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Optional;
|
||||
@@ -20,7 +21,7 @@ public class DescriptionProvider {
|
||||
|
||||
public String getDescriptionForIssue(Issue issue) {
|
||||
String code = issue.getIssuer().getCanonicalName() + issue.getDescriptionCode();
|
||||
String description = descriptions.getProperty(code);
|
||||
String description = StringSubstitutor.replace(descriptions.getProperty(code), issue.getDescriptionModel());
|
||||
return description != null && !description.isEmpty() ? description : "No description provided.";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@@ -12,6 +13,7 @@ public class Issue implements Comparable {
|
||||
private final Class<?> issuer;
|
||||
private final Severity severity;
|
||||
private final String descriptionCode;
|
||||
private final Map<String, String> descriptionModel;
|
||||
private final File file;
|
||||
private final Integer lineNumber;
|
||||
private final String line;
|
||||
|
||||
Reference in New Issue
Block a user