Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parser for CCES (CrossCore Embedded Studio) #937

Merged
merged 8 commits into from
Aug 1, 2023
18 changes: 17 additions & 1 deletion SUPPORTED-FORMATS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--- DO NOT EDIT -- Generated at 2023-07-30T22:54:43.181363 - Run the `main` method of `ParserRegistry` to regenerate after changing parsers -- DO NOT EDIT --->
<!--- DO NOT EDIT -- Generated at 2023-08-01T11:30:25.603198 - Run the `main` method of `ParserRegistry` to regenerate after changing parsers -- DO NOT EDIT --->
# Supported Report Formats

The static analysis model supports the following report formats.
Expand Down Expand Up @@ -517,6 +517,22 @@ If your tool is supported, but some properties are missing (icon, URL, etc.), pl
:bulb: You need to use the Eclipse format with the option <code>--output=eclipse</code>
</td>
</tr>
<tr>
<td>
crosscore-embedded-studio
</td>
<td>
-
</td>
<td>
<a href="https://www.analog.com/en/design-center/evaluation-hardware-and-software/software/adswt-cces.html">
CrossCore Embedded Studio (CCES)
</a>
</td>
<td>
-
</td>
</tr>
<tr>
<td>
dscanner
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package edu.hm.hafner.analysis.parser;

import java.util.Optional;
import java.util.regex.Matcher;

import edu.hm.hafner.analysis.Issue;
import edu.hm.hafner.analysis.IssueBuilder;
import edu.hm.hafner.analysis.LookaheadParser;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.util.LookaheadStream;

/**
* A parser for the CrossCoreEmbeddedStudio (CCES) log files.
*/
public class CrossCoreEmbeddedStudioParser extends LookaheadParser {
private static final long serialVersionUID = 1L;

/* Regex to match the CCES warnings.
*
* Details:
* - See below the MATCHER_* ids to ease their retrieval.
* - Potential columns are ignored
* - Assume warnings description are always spread over two lines (what was observed so far)
* - Errors are not parsed, only warnings
*/
private static final String CCES_WARNING_PATTERN =
arthur-devialet marked this conversation as resolved.
Show resolved Hide resolved
"^\"(?<file>.+?)\", line (?<line>\\d+).*(?<category>cc\\d+).*warning:(?<messageBegin>.*)";

/**
* Creates a new instance of {@link CrossCoreEmbeddedStudioParser}.
*/
public CrossCoreEmbeddedStudioParser() {
super(CCES_WARNING_PATTERN);
}

@Override
protected Optional<Issue> createIssue(final Matcher matcher, final LookaheadStream lookahead,
final IssueBuilder builder) {

StringBuilder message = new StringBuilder(matcher.group("messageBegin").trim());

// always grab the second line
if (lookahead.hasNext()) {

Check warning on line 43 in src/main/java/edu/hm/hafner/analysis/parser/CrossCoreEmbeddedStudioParser.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 43 is only partially covered, one branch is missing
message.append(" ");
message.append(lookahead.next().trim());
}

return builder.setFileName(matcher.group("file"))
.setLineStart(matcher.group("line"))
.setSeverity(Severity.WARNING_NORMAL)
.setCategory(matcher.group("category"))
.setMessage(message.toString())
.buildOptional();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package edu.hm.hafner.analysis.registry;

import edu.hm.hafner.analysis.IssueParser;
import edu.hm.hafner.analysis.parser.CrossCoreEmbeddedStudioParser;

/**
* A descriptor for CrossCore Embedded Studio from Analog Devices.
*/
public class CrossCoreEmbeddedStudioDescriptor extends ParserDescriptor {
private static final String ID = "crosscore-embedded-studio";
uhafner marked this conversation as resolved.
Show resolved Hide resolved
private static final String NAME = "CrossCore Embedded Studio (CCES)";

CrossCoreEmbeddedStudioDescriptor() {
super(ID, NAME);
}

@Override
public IssueParser createParser(final Option... options) {
return new CrossCoreEmbeddedStudioParser();
}

@Override
public String getUrl() {
return "https://www.analog.com/en/design-center/evaluation-hardware-and-software/software/adswt-cces.html";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class ParserRegistry {
new CpdDescriptor(),
new CppCheckDescriptor(),
new CppLintDescriptor(),
new CrossCoreEmbeddedStudioDescriptor(),
new CssLintDescriptor(),
new DartAnalyzeDescriptor(),
new DetektDescriptor(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package edu.hm.hafner.analysis.parser;

import edu.hm.hafner.analysis.AbstractParserTest;
import edu.hm.hafner.analysis.Report;
import edu.hm.hafner.analysis.Severity;
import edu.hm.hafner.analysis.assertions.SoftAssertions;

/**
* Tests the class {@link CrossCoreEmbeddedStudioParser}.
*/
class CrossCoreEmbeddedStudioParserTest extends AbstractParserTest {
CrossCoreEmbeddedStudioParserTest() {
super("cces.log");
}

@Override
protected CrossCoreEmbeddedStudioParser createParser() {
return new CrossCoreEmbeddedStudioParser();
}

@Override
protected void assertThatIssuesArePresent(final Report report, final SoftAssertions softly) {
// check all warnings were caught
softly.assertThat(report).hasSize(6);

// test in details the first warning
softly.assertThat(report.get(0))
.hasFileName("src/dummy_1.c")
.hasLineStart(333)
.hasSeverity(Severity.WARNING_NORMAL)
.hasCategory("cc0188")
.hasMessage("enumerated type mixed with another type");

// test in details the last warning, that has column (but not parsed)
softly.assertThat(report.get(5))
.hasFileName("src/dummy_5.c")
.hasLineStart(125)
.hasSeverity(Severity.WARNING_NORMAL)
.hasCategory("cc1462")
.hasMessage("call to dummy_btc has not been inlined");
}
}
33 changes: 33 additions & 0 deletions src/test/resources/edu/hm/hafner/analysis/parser/cces.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Building libdummy for toolchain sharc_21565...
CC src/dummy_1.c
"src/dummy_1.c", line 333: cc0188: {D} warning:
enumerated type mixed with another type
dummy_get();
^

"src/dummy_2.c", line 36: cc0188: {D} warning: enumerated type
mixed with another type
dummy_get();
^

CC src/dummy_3.c
"src/dummy_3.c", line 149: cc0111: {D} warning: statement is
unreachable
break;
^

CC src/dummy_4.c
"src/dummy_4.c", line 85: cc0188: {D} warning: enumerated type
mixed with another type
dummy_get();
^

"src/dummy_4.c", line 295: cc0111: {D} warning: statement is
unreachable
break;
^

CC src/dummy_5.c
"src/dummy_5.c", line 125 (col. 22): cc1462: {D} warning: call to
dummy_btc has not been inlined

Loading