Skip to content

Commit

Permalink
Removed some deprecated objects
Browse files Browse the repository at this point in the history
Also fixed NPE on SquidSensor
  • Loading branch information
Gilles Grousset committed Aug 30, 2018
1 parent 6fc2980 commit 3eaed8b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.measures.Metric;
import org.sonar.api.test.MutableTestPlan;
import org.sonar.api.test.TestCase;
import org.sonar.api.utils.StaxParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public class ObjectiveCSquidSensor implements Sensor {
private final FilePredicate mainFilePredicates;


private Project project;
private SensorContext context;
private AstScanner<ObjectiveCGrammar> scanner;

public ObjectiveCSquidSensor(RulesProfile profile, FileSystem fileSystem, PathResolver pathResolver, ResourcePerspectives resourcePerspectives, CheckFactory checkFactory) {
public ObjectiveCSquidSensor(SensorContext context, FileSystem fileSystem, PathResolver pathResolver, ResourcePerspectives resourcePerspectives, CheckFactory checkFactory) {

this.context = context;
this.fileSystem = fileSystem;
this.pathResolver = pathResolver;
this.resourcePerspectives = resourcePerspectives;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.issue.Issuable;
import org.sonar.api.issue.Issue;
import org.sonar.api.resources.Project;
import org.sonar.api.rule.RuleKey;

import java.io.File;
Expand All @@ -39,14 +37,10 @@
public class FauxPasReportParser {

private static final Logger LOGGER = LoggerFactory.getLogger(FauxPasReportParser.class);
private final Project project;
private final SensorContext context;
private final ResourcePerspectives resourcePerspectives;
private final FileSystem fileSystem;

public FauxPasReportParser(final Project p, final SensorContext c, final ResourcePerspectives resourcePerspectives, final FileSystem fileSystem) {
project = p;
context = c;
public FauxPasReportParser(final ResourcePerspectives resourcePerspectives, final FileSystem fileSystem) {
this.resourcePerspectives = resourcePerspectives;
this.fileSystem = fileSystem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;

import java.io.File;

Expand All @@ -44,13 +43,11 @@ public class FauxPasSensor implements Sensor {
private final Settings conf;
private final FileSystem fileSystem;
private final ResourcePerspectives resourcePerspectives;
private final Project project;

public FauxPasSensor(final FileSystem moduleFileSystem, final Settings config, final ResourcePerspectives resourcePerspectives, final Project project) {
public FauxPasSensor(final FileSystem moduleFileSystem, final Settings config, final ResourcePerspectives resourcePerspectives) {
this.conf = config;
this.fileSystem = moduleFileSystem;
this.resourcePerspectives = resourcePerspectives;
this.project = project;
}


Expand Down Expand Up @@ -91,7 +88,7 @@ public void execute(SensorContext context) {

final String projectBaseDir = fileSystem.baseDir().getPath();

FauxPasReportParser parser = new FauxPasReportParser(project, context, resourcePerspectives, fileSystem);
FauxPasReportParser parser = new FauxPasReportParser(resourcePerspectives, fileSystem);
parseReportIn(projectBaseDir, parser);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.StaxParser;

import javax.xml.stream.XMLStreamException;
Expand All @@ -32,14 +30,10 @@

final class OCLintParser {

private final Project project;
private final SensorContext context;
private final ResourcePerspectives resourcePerspectives;
private final FileSystem fileSystem;

public OCLintParser(final Project p, final SensorContext c, final ResourcePerspectives resourcePerspectives, final FileSystem fileSystem) {
project = p;
context = c;
public OCLintParser(final ResourcePerspectives resourcePerspectives, final FileSystem fileSystem) {
this.resourcePerspectives = resourcePerspectives;
this.fileSystem = fileSystem;
}
Expand All @@ -60,7 +54,7 @@ public void parseReport(final InputStream inputStream) {

try {
final StaxParser parser = new StaxParser(
new OCLintXMLStreamHandler(project, context, resourcePerspectives, fileSystem));
new OCLintXMLStreamHandler(resourcePerspectives, fileSystem));
parser.parse(inputStream);
} catch (final XMLStreamException e) {
LoggerFactory.getLogger(getClass()).error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.config.Settings;
import org.sonar.api.resources.Project;

import java.io.File;

Expand All @@ -39,13 +38,11 @@ public final class OCLintSensor implements Sensor {
private final Settings conf;
private final FileSystem fileSystem;
private final ResourcePerspectives resourcePerspectives;
private final Project project;

public OCLintSensor(final FileSystem fileSystem, final Settings config, final ResourcePerspectives resourcePerspectives, final Project project) {
public OCLintSensor(final FileSystem fileSystem, final Settings config, final ResourcePerspectives resourcePerspectives) {
this.conf = config;
this.fileSystem = fileSystem;
this.resourcePerspectives = resourcePerspectives;
this.project = project;
}

private void parseReportIn(final String baseDir, final OCLintParser parser) {
Expand Down Expand Up @@ -82,7 +79,7 @@ public void describe(SensorDescriptor descriptor) {
@Override
public void execute(SensorContext context) {
final String projectBaseDir = fileSystem.baseDir().getPath();
final OCLintParser parser = new OCLintParser(project, context, resourcePerspectives, fileSystem);
final OCLintParser parser = new OCLintParser(resourcePerspectives, fileSystem);

parseReportIn(projectBaseDir, parser);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.issue.Issuable;
import org.sonar.api.issue.Issue;
import org.sonar.api.resources.Project;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.StaxParser.XmlStreamHandler;

Expand All @@ -35,14 +33,10 @@

final class OCLintXMLStreamHandler implements XmlStreamHandler {
private static final int PMD_MINIMUM_PRIORITY = 5;
private final Project project;
private final SensorContext context;
private final ResourcePerspectives resourcePerspectives;
private final FileSystem fileSystem;

public OCLintXMLStreamHandler(final Project p, final SensorContext c, final ResourcePerspectives resourcePerspectives, final FileSystem fileSystem) {
project = p;
context = c;
public OCLintXMLStreamHandler(final ResourcePerspectives resourcePerspectives, final FileSystem fileSystem) {
this.resourcePerspectives = resourcePerspectives;
this.fileSystem = fileSystem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import org.sonar.api.issue.Issuable;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Resource;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.squidbridge.AstScanner;
Expand All @@ -66,12 +64,12 @@ public class SwiftSquidSensor implements Sensor {
private final Checks<SquidCheck<SwiftGrammar>> checks;
private final FilePredicate mainFilePredicates;

private Project project;
private SensorContext context;
private AstScanner<SwiftGrammar> scanner;

public SwiftSquidSensor(RulesProfile profile, FileSystem fileSystem, PathResolver pathResolver, ResourcePerspectives resourcePerspectives, CheckFactory checkFactory) {
public SwiftSquidSensor(SensorContext context, FileSystem fileSystem, PathResolver pathResolver, ResourcePerspectives resourcePerspectives, CheckFactory checkFactory) {

this.context = context;
this.fileSystem = fileSystem;
this.pathResolver = pathResolver;
this.resourcePerspectives = resourcePerspectives;
Expand Down

0 comments on commit 3eaed8b

Please sign in to comment.