Skip to content

Commit

Permalink
Update #23 edit references of Violation in Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Omar WALDMANN committed May 30, 2017
1 parent cd57e2a commit 1916a4f
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,34 @@ public abstract class AbstractRule extends AbstractEvaluation {
/** Analysed file. */
private File file;

/** List of violations found during analysis. **/
/** List of {@link CheckResult} found during analysis. **/
private List<CheckResult> checkResults;

private CheckResult checkResult;// TODO à voir pour l'enlever

/**
* Getter for the list of violations.
* Getter for the list of {@link CheckResult}.
*
* @return the violations
* @return the {@link CheckResult}s
*/
public List<CheckResult> getCheckResults() {
return this.checkResults;
}

/**
* Setter for the list of violations.
* Setter for the list of {@link CheckResult}s.
*
* @param pCheckResults
* the violations to set
* the {@link CheckResult}s to set
*/
public void setViolations(final List<CheckResult> pCheckResults) {
public void setCheckResults(final List<CheckResult> pCheckResults) {
this.checkResults = pCheckResults;
}

/**
* Run analysis for considering file and rule.
*
* @return list of {@link fr.cnes.analysis.tools.analyzer.datas.Violation}
* found during analysis
* @return list of {@link CheckResult}s found during analysis
* @throws IOException
* IO problem occurred
* @throws JFlexException
Expand All @@ -59,7 +58,7 @@ public void setViolations(final List<CheckResult> pCheckResults) {
public abstract List<CheckResult> run() throws IOException, JFlexException;

/**
* Method to add a violation, knowing its location and line.
* Method to add a {@link CheckResult}, knowing its location and line.
*
* @param pLocation
* the location
Expand All @@ -86,7 +85,7 @@ protected void setError(final String pLocation, final String pMessage, final int
}

/**
* Method to add a violation, knowing its location and line.
* Method to add a {@link CheckResult}, knowing its location and line.
*
* @param pLocation
* the location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CheckResult {
/** Check line. */
private Integer line;

/** Violation message. */
/** {@link CheckResult} message. */
private String message;

/** Metric value. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class Checker {
private List<CheckResult> checkResults = new LinkedList<CheckResult>();;

/**
* Method to add a violation, knowing its location and line.
* Method to add a {@link CheckResult}, knowing its location and line.
*
* @param pLocation
* the location
*
* @param pMessage
* violation's message
* {@link CheckResult}'s message
* @param pLine
* the line
* @throws JFlexException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* </p>
* <p>
* This class is responsible of the export in the format CSV of
* {@link Violation} elements into a {@link File}.
* {@link CheckResult} elements into a {@link File}.
* </p>
*
* @since 3.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* </p>
* <p>
* This class is responsible of the export in the format XML of
* {@link Violation} elements into a {@link File}.
* {@link CheckResult} elements into a {@link File}.
* </p>
*
* @since 3.0
Expand Down Expand Up @@ -91,7 +91,7 @@ public void export(List<CheckResult> checkResults, File outputFile) throws IOExc
document.getRootElement().addContent(analysisInformation);
// -- <xsd:element name="analysisFile" type="anr:analysisFileType"
// -- minOccurs="0" maxOccurs="unbounded" />
for (final CheckResult violation : checkResults) {
for (final CheckResult checkResult : checkResults) {
attributes.clear();

// -- <xsd:attribute name="fileName" type="xsd:string"
Expand All @@ -100,8 +100,8 @@ public void export(List<CheckResult> checkResults, File outputFile) throws IOExc
// get
// the filename.
// -- <xsd:attribute name="language" type="xsd:string" />
final String language = this.getFileExtension(violation.getFile().getAbsolutePath());
final String fileName = violation.getFile().toString();
final String language = this.getFileExtension(checkResult.getFile().getAbsolutePath());
final String fileName = checkResult.getFile().toString();
// The analysisFile element is being added only and only if it's not
// already in the XML document.
boolean analysisFileMarked = false;
Expand All @@ -122,21 +122,21 @@ public void export(List<CheckResult> checkResults, File outputFile) throws IOExc
Element result = null;
Element analysisRule = null;
int resultId = 1;
for (final CheckResult violation : checkResults) {
for (final CheckResult checkResult : checkResults) {
boolean elementAlreadyExisting = false;
Element existingElement = null;
for (final Element element : document.getRootElement().getChildren("analysisRule")) {
for (final Attribute attribute : element.getAttributes()) {
if (attribute.getName().equals("analysisRuleId")
&& attribute.getValue().equals(violation.getId())) {
&& attribute.getValue().equals(checkResult.getId())) {
elementAlreadyExisting = true;
existingElement = element;
}
}
}
if (!elementAlreadyExisting || existingElement == null) {
analysisRule = new Element("analysisRule");
analysisRule.setAttribute(new Attribute("analysisRuleId", violation.getName()));
analysisRule.setAttribute(new Attribute("analysisRuleId", checkResult.getName()));
} else {
analysisRule = existingElement;
}
Expand All @@ -148,22 +148,22 @@ public void export(List<CheckResult> checkResults, File outputFile) throws IOExc

resultAttributes.add(new Attribute("resultId", Integer.toString(resultId)));
resultId++;
resultAttributes.add(new Attribute("fileName", violation.getFile().toString()));
resultAttributes.add(new Attribute("resultLine", violation.getLine().toString()));
resultAttributes.add(new Attribute("fileName", checkResult.getFile().toString()));
resultAttributes.add(new Attribute("resultLine", checkResult.getLine().toString()));

/*
* The location and message are defined in violations by only one
* attribute (String) made this way: [Location -> Message], so we
* split it to get the two exploitable strings.
*/
resultAttributes.add(new Attribute("resultNamePlace", violation.getLocation()));
resultAttributes.add(new Attribute("resultNamePlace", checkResult.getLocation()));
/*
* The result message is defined by the XSD as a sequence of element
* resultMessage (not an attribute).
*/
final Element resultMessage = new Element("resultMessage");

resultMessage.addContent(violation.getMessage());
resultMessage.addContent(checkResult.getMessage());

result.addContent(resultMessage);
result.setAttributes(resultAttributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ private IConfigurationElement[] getContributions() {
}

/**
* This function export each {@link Violation} of the {@code violations}
* This function export each {@link CheckResult} of {@code checkResults}
* parameter into the {@link File} parameter.
*
* @param violations
* @param checkResults
* to export.
* @param outputFile
* to use for the export.
Expand All @@ -91,17 +91,17 @@ private IConfigurationElement[] getContributions() {
* when the export failed due to a {@link java.io.File}
* exception.
*/
public void export(List<CheckResult> violations, File outputFile)
public void export(List<CheckResult> checkResults, File outputFile)
throws NoContributorMatchingException, NoExtensionIndicatedException, IOException {
IExport exporter = this
.getExportClass(this.getExtensionFromFilePath(outputFile.getAbsolutePath()));
exporter.export(violations, outputFile);
exporter.export(checkResults, outputFile);
}

/**
* @param inputFile
* to realize the import on.
* @return the list of {@link Violation} extracted from the
* @return the list of {@link CheckResult} extracted from the
* {@code inputFile}.
* @throws NoExtensionIndicatedException
* when the {@code inputFile} do not end with an extension.
Expand All @@ -112,14 +112,14 @@ public void export(List<CheckResult> violations, File outputFile)
*/
public List<CheckResult> importResults(File inputFile)
throws NoExtensionIndicatedException, NoContributorMatchingException {
List<CheckResult> violations = null;
List<CheckResult> checkResults = null;
IImport importer = this
.getImportClass(this.getExtensionFromFilePath(inputFile.getAbsolutePath()));
violations = importer.importResults(inputFile);
if (violations == null) {
checkResults = importer.importResults(inputFile);
if (checkResults == null) {
throw new NoContributorMatchingException();
}
return violations;
return checkResults;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
public interface IExport {

/**
* This function exports {@link Violation} of {@code violations} into
* This function exports {@link CheckResult} of {@code checkResults} into
* {@link File} indicated pending it's format.
*
* @param checkResults
* to exports.
* @param outputFile
* to write the violations.
* to write the {@link CheckResult}s.
* @throws IOException
* when a {@link java.io.File} exception occur while using
* {@code outputFile}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public interface IImport {

/**
* @param inputFile
* containing the {@link Violation} to import.
* @return the violations in a List of {@link Violation} data.
* containing the {@link CheckResult} to import.
* @return the checkReults in a List of {@link CheckResult} data.
*/
public List<CheckResult> importResults(File inputFile);

Expand Down

0 comments on commit 1916a4f

Please sign in to comment.