Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
Added support for SonarCube in the warnings plug-in.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jul 10, 2018
1 parent e8726d5 commit d5fa787
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/main/java/io/jenkins/plugins/analysis/warnings/SonarCube.java
@@ -0,0 +1,80 @@
package io.jenkins.plugins.analysis.warnings;

import javax.annotation.Nonnull;

import org.kohsuke.stapler.DataBoundConstructor;

import edu.hm.hafner.analysis.IssueParser;
import edu.hm.hafner.analysis.parser.SonarQubeIssuesParser;
import static hudson.plugins.warnings.WarningsDescriptor.*;
import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider;
import io.jenkins.plugins.analysis.core.model.StaticAnalysisTool;

import hudson.Extension;

/**
* Provides parsers and customized messages for SonarQube.
*
* @author Ullrich Hafner
*/
public class SonarCube extends StaticAnalysisTool {
static final String ID = "sonar";

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

@Override
public IssueParser createParser() {
return new SonarQubeIssuesParser();
}

/** Provides the labels for the static analysis tool. */
private static class LabelProvider extends StaticAnalysisLabelProvider {
private static final String SMALL_ICON_URL = IMAGE_PREFIX + ID + "-24x24.png";
private static final String LARGE_ICON_URL = IMAGE_PREFIX + ID + "-48x48.png";

LabelProvider() {
super(ID, Messages.Warnings_SonarQube_ParserName());
}

@Override
public String getSmallIconUrl() {
return SMALL_ICON_URL;
}

@Override
public String getLargeIconUrl() {
return LARGE_ICON_URL;
}
}


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

@Nonnull
@Override
public String getDisplayName() {
return Messages.Warnings_SonarQube_ParserName();
}

@Override
public StaticAnalysisLabelProvider getLabelProvider() {
return new LabelProvider();
}

@Override
public String getPattern() {
return "**/sonar-report.json";
}
}
}
Expand Up @@ -20,6 +20,8 @@ Warnings.CPD.ParserName=CPD
Warnings.DupFinder.ParserName=Resharper dupFinder
Warnings.Simian.ParserName=Simian

Warnings.SonarQube.ParserName=SonarQube

Warnings.ClangTidy.ParserName=Clang-Tidy

Warnings.CheckStyle.ParserName=CheckStyle
Expand Down
Binary file added src/main/webapp/icons/sonar_24x24.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/webapp/icons/sonar_48x48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d5fa787

Please sign in to comment.