Skip to content

Commit

Permalink
Added Cargo and Cmake tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Apr 26, 2019
1 parent 0efa103 commit fcf33e4
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 124 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Additional new features:
Support for [IBLinter](https://github.com/IBDecodable/IBLinter) - Xcode Storyboard Linter
- [PR#21](https://github.com/jenkinsci/warnings-ng-plugin/pull/21):
Support for [PHPStan](https://github.com/phpstan/phpstan) - PHP Static Analysis Tool
- [PR#132](https://github.com/jenkinsci/analysis-model/pull/132):
Added a parser for CMake warnings.
- [PR#137](https://github.com/jenkinsci/analysis-model/pull/137):
Added a parser for JSON output from Cargo.

### Fixed

Expand Down
182 changes: 92 additions & 90 deletions SUPPORTED-FORMATS.md

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions src/main/java/io/jenkins/plugins/analysis/warnings/Cargo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package io.jenkins.plugins.analysis.warnings;

import edu.hm.hafner.analysis.parser.CargoCheckParser;
import edu.umd.cs.findbugs.annotations.NonNull;

import org.kohsuke.stapler.DataBoundConstructor;
import org.jenkinsci.Symbol;
import hudson.Extension;

import io.jenkins.plugins.analysis.core.model.ReportScanningTool;

/**
* Provides a parser and customized messages for {@code rustc} compiler messages emitted b {@code cargo check
* --message-format json}.
*
* @author Ullrich Hafner
*/
public class Cargo extends ReportScanningTool {
private static final long serialVersionUID = -3997235880208767455L;
private static final String ID = "cargo";

/** Creates a new instance of {@link Cargo}. */
@DataBoundConstructor
public Cargo() {
super();
// empty constructor required for stapler
}

@Override
public CargoCheckParser createParser() {
return new CargoCheckParser();
}

/** Descriptor for this static analysis tool. */
@Symbol("cargo")
@Extension
public static class Descriptor extends ReportScanningToolDescriptor {
/** Creates the descriptor instance. */
public Descriptor() {
super(ID);
}

@NonNull
@Override
public String getDisplayName() {
return Messages.Warnings_Cargo_ParserName();
}

@Override
public String getHelp() {
return "Use commandline <code>cargo check --message-format json</code>";
}
}
}
48 changes: 48 additions & 0 deletions src/main/java/io/jenkins/plugins/analysis/warnings/Cmake.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.jenkins.plugins.analysis.warnings;

import edu.hm.hafner.analysis.parser.CMakeParser;
import edu.umd.cs.findbugs.annotations.NonNull;

import org.kohsuke.stapler.DataBoundConstructor;
import org.jenkinsci.Symbol;
import hudson.Extension;

import io.jenkins.plugins.analysis.core.model.ReportScanningTool;

/**
* Provides parser and customized messages for CMake.
*
* @author Ullrich Hafner
*/
public class Cmake extends ReportScanningTool {
private static final long serialVersionUID = -5981880343845273634L;
private static final String ID = "cmake";

/** Creates a new instance of {@link Cmake}. */
@DataBoundConstructor
public Cmake() {
super();
// empty constructor required for stapler
}

@Override
public CMakeParser createParser() {
return new CMakeParser();
}

/** Descriptor for this static analysis tool. */
@Symbol("cmake")
@Extension
public static class Descriptor extends ReportScanningToolDescriptor {
/** Creates the descriptor instance. */
public Descriptor() {
super(ID);
}

@NonNull
@Override
public String getDisplayName() {
return Messages.Warnings_Cmake_ParserName();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public Descriptor() {
super(ID);
}

@Override
public String getHelp() {
return Messages.Warning_SlowMultiLineParser();
}

@NonNull
@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public Descriptor() {
super(ID);
}

@Override
public String getHelp() {
return Messages.Warning_SlowMultiLineParser();
}

@NonNull
@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public Descriptor() {
super(ID);
}

@Override
public String getHelp() {
return Messages.Warning_SlowMultiLineParser();
}

@NonNull
@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public Descriptor() {
super(ID);
}

@Override
public String getHelp() {
return Messages.Warning_SlowMultiLineParser();
}

@NonNull
@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public Descriptor() {
super(ID);
}

@Override
public String getHelp() {
return Messages.Warning_SlowMultiLineParser();
}

@NonNull
@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ public Descriptor() {
super(ID);
}

@Override
public String getHelp() {
return Messages.Warning_SlowMultiLineParser();
}

@NonNull
@Override
public String getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ OpenTasks.Validation.NoTask=No open task found.
OpenTasks.Validation.OneTask=One open task: {0} - {1}
OpenTasks.Validation.MultipleTasks={0} open tasks found.

Warning.SlowMultiLineParser=Warning: this parser might be slow since it is reading the whole report file into memory \
and parses this String using a slow multi-line regular expression.

Warnings.Groovy.NoParsersDefined=- no parser defined yet -
Warnings.Groovy.DescribableName=Groovy Parser

Expand Down Expand Up @@ -52,12 +49,13 @@ Warnings.PMD.ParserName=PMD
Warnings.FindBugs.ParserName=FindBugs
Warnings.SpotBugs.ParserName=SpotBugs
Warnings.ScalaStyle.ParserName=ScalaStyle
Warnings.Cmake.ParserName=CMake
Warnings.Cargo.ParserName=Cargo

Warnings.AcuCobol.ParserName=AcuCobol Compiler
Warnings.JavaParser.ParserName=Java
Warnings.JavaDoc.ParserName=JavaDoc
Warnings.EclipseParser.ParserName=Eclipse ECJ

Warnings.Taglist.ParserName=Maven Taglist Plugin
Warnings.Maven.ParserName=Maven
Warnings.CppLint.ParserName=CppLint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ public void shouldFindAllIssuesForCheckStyleAlias() {
}
}

/** Runs the Iar parser on an output file that contains 8 issues. */
@Test
public void shouldFindAllCmakeIssues() {
shouldFindIssuesOfTool(8, new Cmake(), "cmake.txt");
}

/** Runs the Iar parser on an output file that contains 2 issues. */
@Test
public void shouldFindAllCargoIssues() {
shouldFindIssuesOfTool(2, new Cargo(), "CargoCheck.json");
}

/** Runs the Iar parser on an output file that contains 262 issues. */
@Test
public void shouldFindAllIssuesForPmdAlias() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{"reason":"compiler-artifact","package_id":"smol_str 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)","target":{"kind":["lib"],"crate_types":["lib"],"name":"smol_str","src_path":".cargo/registry/src/github.com-1ecc6299db9ec823/smol_str-0.1.9/src/lib.rs","edition":"2015"},"profile":{"opt_level":"0","debuginfo":2,"debug_assertions":true,"overflow_checks":true,"test":false},"features":[],"filenames":["/target/debug/deps/libsmol_str-60034903e8f9c710.rmeta"],"executable":null,"fresh":false}
{"reason":"compiler-message","package_id":"dummy-pkg","target":{"kind":["bin"],"crate_types":["bin"],"name":"secspc","src_path":"src/main.rs","edition":"2018"},"message":{"message":"unused import: `secsp_analysis::input::FileId`","code":{"code":"unused_imports","explanation":null},"level":"warning","spans":[{"file_name":"packages/secspc/src/main.rs","byte_start":199,"byte_end":228,"line_start":14,"line_end":14,"column_start":5,"column_end":34,"is_primary":true,"text":[{"text":"use secsp_analysis::input::FileId;","highlight_start":5,"highlight_end":34}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"#[warn(unused_imports)] on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: unused import: `secsp_analysis::input::FileId`\n --> packages/secspc/src/main.rs:14:5\n |\n14 | use secsp_analysis::input::FileId;\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = note: #[warn(unused_imports)] on by default\n\n"}}
{"reason":"compiler-message","package_id":"dummy-pkg","target":{"kind":["bin"],"crate_types":["bin"],"name":"secspc","src_path":"packages/secspc/src/main.rs","edition":"2018"},"message":{"message":"dummy message","code":{"code":"dummy_code","explanation":null},"level":"warning","spans":[],"children":[],"rendered":"dummy message"}}
{"reason":"compiler-message","package_id":"dummy-pkg","target":{"kind":["bin"],"crate_types":["bin"],"name":"secspc","src_path":"packages/secspc/src/main.rs","edition":"2018"},"message":{"message":"redundant closure found","code":{"code":"clippy::redundant_closure","explanation":null},"level":"warning","spans":[{"file_name":"packages/secspc/src/main.rs","byte_start":1651,"byte_end":1671,"line_start":68,"line_end":68,"column_start":14,"column_end":34,"is_primary":false,"label":"secondary text here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"packages/secspc/src/main.rs","byte_start":1651,"byte_end":1671,"line_start":68,"line_end":68,"column_start":14,"column_end":34,"is_primary":true,"text":[{"text":" .map(|i| PathBuf::from(i))","highlight_start":14,"highlight_end":34}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"#[warn(clippy::redundant_closure)] on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"remove closure as shown","code":null,"level":"help","spans":[{"file_name":"packages/secspc/src/main.rs","byte_start":1651,"byte_end":1671,"line_start":68,"line_end":68,"column_start":14,"column_end":34,"is_primary":true,"text":[{"text":" .map(|i| PathBuf::from(i))","highlight_start":14,"highlight_end":34}],"label":null,"suggested_replacement":"PathBuf::from","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: redundant closure found\n --> packages/secspc/src/main.rs:68:14\n |\n68 | .map(|i| PathBuf::from(i))\n | ^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `PathBuf::from`\n |\n = note: #[warn(clippy::redundant_closure)] on by default\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure\n\n"}}
22 changes: 22 additions & 0 deletions src/test/resources/io/jenkins/plugins/analysis/warnings/cmake.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[step1] CMake Warning:
[step1] Manually-specified variables were not used by the project

[step2] CMake Warning in CMakeLists.txt:
[step2] The build directory is a subdirectory of the source directory.

CMake Warning (dev) at tools/gtest-1.8/googlemock/CMakeLists.txt:10 (option):
I'm the message

CMake Warning at project/utils/fancy.cmake:423 (message):
Special workaround applied

CMake Error at error.cmake:2 (message):
Uh oh !$%@!

CMake Deprecation Warning at legacy.cmake:23 (message):
function foo is deprecated, use bar instead

CMake Warning at unlikely.cmake:357 nonexistingcategory:
strange things can happen

CMake Warning at unlikely.cmake:362 (message):

0 comments on commit fcf33e4

Please sign in to comment.