diff --git a/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java b/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java index b3cbd3ac8..07dcb539f 100644 --- a/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java +++ b/src/main/java/edu/hm/hafner/analysis/parser/CargoCheckParser.java @@ -17,52 +17,52 @@ import edu.hm.hafner.analysis.Severity; /** - * A parser for {@code rustc} compiler messages in the JSON format emitted by {@code cargo check --message-format - * json}. + * A parser for {@code rustc} compiler messages in the JSON format emitted by {@code cargo check --message-format json}. + * . */ public class CargoCheckParser extends IssueParser { private static final long serialVersionUID = 7953467739178377581L; - /** The {@link #REASON} associated with messages that have code analysis information */ + /** The {@link #REASON} associated with messages that have code analysis information. */ private static final String ANALYSIS_MESSAGE_REASON = "compiler-message"; - /** Top-level key indicating the reason for a message to be emitted, we only care about compiler-message */ + /** Top-level key indicating the reason for a message to be emitted, we only care about compiler-message. */ private static final String REASON = "reason"; - /** Top-level key containing the code analysis message */ + /** Top-level key containing the code analysis message. */ private static final String MESSAGE = "message"; - /** Key for {@code message.code}, an object containing the message category */ + /** Key for {@code message.code}, an object containing the message category. */ private static final String MESSAGE_CODE = "code"; - /** Key for {@code message.code.code}, a string representation of the message category */ + /** Key for {@code message.code.code}, a string representation of the message category. */ private static final String MESSAGE_CODE_CATEGORY = "code"; - /** Key for {@code message.rendered}, the rendered string representation of the message */ + /** Key for {@code message.rendered}, the rendered string representation of the message. */ private static final String MESSAGE_RENDERED = "message"; - /** Key for {@code message.level}, the string representation of the message severity */ + /** Key for {@code message.level}, the string representation of the message severity. */ private static final String MESSAGE_LEVEL = "level"; - /** Key for {@code message.spans}, an array of message location information */ + /** Key for {@code message.spans}, an array of message location information. */ private static final String MESSAGE_SPANS = "spans"; - /** Key for {@code message.spans.is_primary}, a boolean indicating if this is the primary error location" */ + /** Key for {@code message.spans.is_primary}, a boolean indicating if this is the primary error location". */ private static final String MESSAGE_SPAN_IS_PRIMARY = "is_primary"; - /** Key for {@code message.spans.file_name}, a relative path to the file the message was emitted for */ + /** Key for {@code message.spans.file_name}, a relative path to the file the message was emitted for. */ private static final String MESSAGE_SPAN_FILE_NAME = "file_name"; - /** Key for {@code message.spans.line_start}, the line number where the associated code starts */ + /** Key for {@code message.spans.line_start}, the line number where the associated code starts. */ private static final String MESSAGE_SPAN_LINE_START = "line_start"; - /** Key for {@code message.spans.line_end}, the line number where the associated code ends */ + /** Key for {@code message.spans.line_end}, the line number where the associated code ends. */ private static final String MESSAGE_SPAN_LINE_END = "line_end"; - /** Key for {@code message.spans.column_start}, the column number where the associated code starts */ + /** Key for {@code message.spans.column_start}, the column number where the associated code starts. */ private static final String MESSAGE_SPAN_COLUMN_START = "column_start"; - /** Key for {@code message.spans.column_end}, the column number where the associated code ends */ + /** Key for {@code message.spans.column_end}, the column number where the associated code ends. */ private static final String MESSAGE_SPAN_COLUMN_END = "column_end"; @Override @@ -82,7 +82,9 @@ public Report parse(final ReaderFactory readerFactory) throws ParsingException, /** * Extract the compiler message from a cargo event if any is present. - * @param object A cargo event that may contain a compiler message. + * + * @param object + * A cargo event that may contain a compiler message. * * @return a built {@link Issue} object if any was present. */ @@ -132,6 +134,9 @@ private Optional parseDetails(final JSONObject message) return Optional.empty(); } + /** + * A simplified representation of a primary {@code span} object in the {@code message.spans} an array. + */ private static final class CompilerMessageDetails { private final String fileName; private final int lineStart;