@@ -23,7 +23,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.postjob.PostJobContext; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
import org.sonar.api.batch.postjob.issue.Issue; | |||
import org.sonar.api.batch.postjob.issue.PostJobIssue; | |||
import org.sonar.api.utils.log.LogTester; | |||
import java.util.Arrays; | |||
@@ -41,8 +41,8 @@ public class XooPostJobTest { | |||
public void increaseCoverage() { | |||
new XooPostJob().describe(new DefaultPostJobDescriptor()); | |||
PostJobContext context = mock(PostJobContext.class); | |||
when(context.issues()).thenReturn(Arrays.<Issue>asList()); | |||
when(context.resolvedIssues()).thenReturn(Arrays.<Issue>asList()); | |||
when(context.issues()).thenReturn(Arrays.<PostJobIssue>asList()); | |||
when(context.resolvedIssues()).thenReturn(Arrays.<PostJobIssue>asList()); | |||
new XooPostJob().execute(context); | |||
assertThat(logTester.logs()).contains("Resolved issues: 0", "Open issues: 0"); | |||
} |
@@ -19,15 +19,16 @@ | |||
*/ | |||
package org.sonar.api.batch; | |||
import org.sonar.api.resources.Resource; | |||
import java.util.List; | |||
import org.sonar.api.resources.Resource; | |||
/** | |||
* A pre-implementation of the CpdMapping extension point | |||
* | |||
* @since 1.10 | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
public abstract class AbstractCpdMapping implements CpdMapping { | |||
/** |
@@ -23,7 +23,9 @@ import org.sonar.api.utils.SonarException; | |||
/** | |||
* @since 1.10 | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
@Phase(name = Phase.Name.POST) | |||
public abstract class BuildBreaker implements PostJob { | |||
@@ -23,7 +23,9 @@ import org.sonar.api.resources.Project; | |||
/** | |||
* @since 1.10 | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
public interface CheckProject { | |||
boolean shouldExecuteOnProject(Project project); |
@@ -29,7 +29,7 @@ import org.sonar.api.resources.Resource; | |||
/** | |||
* Implement this extension to get Copy/Paste detection for your language. | |||
* @since 1.10 | |||
* @deprecated since 5.5 | |||
* @deprecated since 5.5 use {@link SensorContext#newCpdTokens()} | |||
*/ | |||
@BatchSide | |||
@ExtensionPoint |
@@ -28,7 +28,9 @@ package org.sonar.api.batch; | |||
* </ul> | |||
* | |||
* @since 2.3 | |||
* @deprecated since 5.6 no more used since Decorators are deprecated | |||
*/ | |||
@Deprecated | |||
public interface DecoratorBarriers { | |||
/** | |||
@@ -47,7 +49,6 @@ public interface DecoratorBarriers { | |||
*/ | |||
String ISSUES_TRACKED = "END_OF_VIOLATION_TRACKING"; | |||
/** | |||
* @deprecated in 3.6. Not required anymore. | |||
*/ |
@@ -30,7 +30,9 @@ import org.sonar.api.resources.Resource; | |||
/** | |||
* @since 1.10 | |||
* @deprecated since 5.6 no more used since Decorator is deprecated | |||
*/ | |||
@Deprecated | |||
public interface DecoratorContext { | |||
/** |
@@ -26,12 +26,8 @@ import org.sonar.api.resources.Project; | |||
* <p> | |||
* Initializer can execute external tool (like a Maven plugin), change project configuration. For example CoberturaMavenInitializer invokes | |||
* the Codehaus Cobertura Mojo and sets path to Cobertura report according to Maven POM. | |||
* | |||
* | |||
* <p> | |||
* Initializers are executed first and once during project analysis. | |||
* | |||
* | |||
* @since 2.6 | |||
*/ | |||
@BatchSide |
@@ -29,7 +29,9 @@ import org.sonar.api.resources.Project; | |||
* it is an asynchronous processing on server side. | |||
* | |||
* @since 1.10 | |||
* @deprecated since 5.6 use {@link org.sonar.api.batch.postjob.PostJob} | |||
*/ | |||
@Deprecated | |||
@BatchSide | |||
@ExtensionPoint | |||
public interface PostJob { |
@@ -40,7 +40,9 @@ import org.sonar.api.resources.Project; | |||
* | |||
* | |||
* @since 1.10 | |||
* @deprecated since 5.6 use {@link org.sonar.api.batch.sensor.Sensor} | |||
*/ | |||
@Deprecated | |||
@BatchSide | |||
@ExtensionPoint | |||
public interface Sensor extends CheckProject { |
@@ -32,7 +32,9 @@ import org.sonar.api.resources.Resource; | |||
/** | |||
* @since 1.10 | |||
* @deprecated since 5.6 use {@link org.sonar.api.batch.sensor.Sensor} | |||
*/ | |||
@Deprecated | |||
public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext { | |||
/** |
@@ -22,6 +22,7 @@ package org.sonar.api.batch; | |||
import java.util.Collection; | |||
import javax.annotation.CheckForNull; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.design.Dependency; | |||
import org.sonar.api.measures.Measure; | |||
import org.sonar.api.measures.MeasuresFilter; |
@@ -19,19 +19,17 @@ | |||
*/ | |||
package org.sonar.api.batch.postjob; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.BatchSide; | |||
import org.sonar.api.ExtensionPoint; | |||
import org.sonar.api.batch.BatchSide; | |||
/** | |||
* PostJobs are executed at the very end of batch analysis. A PostJob can't do any modification | |||
* PostJobs are executed at the very end of scanner analysis. A PostJob can't do any modification | |||
* since everything is already computed (issues, measures,...). <br> | |||
* WANRING: Do not rely on the fact that analysis results are available on server side using WS since this is an | |||
* WARNING: Do not rely on the fact that analysis results are available on server side when using WS since this is an | |||
* asynchronous process to compute data on server side in 5.x series. | |||
* | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
@BatchSide | |||
@ExtensionPoint | |||
public interface PostJob { | |||
@@ -42,7 +40,7 @@ public interface PostJob { | |||
void describe(PostJobDescriptor descriptor); | |||
/** | |||
* The actual sensor code. | |||
* Called at the end of the analysis. | |||
*/ | |||
void execute(PostJobContext context); | |||
@@ -19,16 +19,13 @@ | |||
*/ | |||
package org.sonar.api.batch.postjob; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.postjob.issue.Issue; | |||
import org.sonar.api.batch.postjob.issue.PostJobIssue; | |||
import org.sonar.api.config.Settings; | |||
/** | |||
* See {@link PostJob#execute(PostJobContext)} | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public interface PostJobContext { | |||
/** | |||
@@ -36,21 +33,16 @@ public interface PostJobContext { | |||
*/ | |||
Settings settings(); | |||
/** | |||
* Get analysis mode. | |||
*/ | |||
AnalysisMode analysisMode(); | |||
// ----------- ISSUES -------------- | |||
// ----------- Only available in preview mode -------------- | |||
/** | |||
* All the unresolved issues of the project, including the issues reported by end-users. | |||
*/ | |||
Iterable<Issue> issues(); | |||
Iterable<PostJobIssue> issues(); | |||
/** | |||
* All the issues of this project that have been marked as resolved during this scan | |||
*/ | |||
Iterable<Issue> resolvedIssues(); | |||
Iterable<PostJobIssue> resolvedIssues(); | |||
} |
@@ -19,15 +19,12 @@ | |||
*/ | |||
package org.sonar.api.batch.postjob; | |||
import com.google.common.annotations.Beta; | |||
/** | |||
* Describe what a {@link PostJob} is doing. Information may be used by the platform | |||
* to log interesting information or perform some optimization. | |||
* See {@link PostJob#describe(PostJobDescriptor)} | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public interface PostJobDescriptor { | |||
/** | |||
@@ -47,9 +44,4 @@ public interface PostJobDescriptor { | |||
*/ | |||
PostJobDescriptor requireProperties(String... propertyKeys); | |||
/** | |||
* Should this PostJob be disabled in issues mode. Default is to run all PostJobs in preview mode. | |||
*/ | |||
PostJobDescriptor disabledInIssues(); | |||
} |
@@ -19,16 +19,14 @@ | |||
*/ | |||
package org.sonar.api.batch.postjob.internal; | |||
import org.sonar.api.batch.postjob.PostJobDescriptor; | |||
import java.util.Arrays; | |||
import java.util.Collection; | |||
import org.sonar.api.batch.postjob.PostJobDescriptor; | |||
public class DefaultPostJobDescriptor implements PostJobDescriptor { | |||
private String name; | |||
private String[] properties = new String[0]; | |||
private boolean disabledInIssues = false; | |||
public String name() { | |||
return name; | |||
@@ -38,10 +36,6 @@ public class DefaultPostJobDescriptor implements PostJobDescriptor { | |||
return Arrays.asList(properties); | |||
} | |||
public boolean isDisabledInIssues() { | |||
return disabledInIssues; | |||
} | |||
@Override | |||
public DefaultPostJobDescriptor name(String name) { | |||
this.name = name; | |||
@@ -59,10 +53,4 @@ public class DefaultPostJobDescriptor implements PostJobDescriptor { | |||
return this; | |||
} | |||
@Override | |||
public DefaultPostJobDescriptor disabledInIssues() { | |||
this.disabledInIssues = true; | |||
return this; | |||
} | |||
} |
@@ -19,19 +19,17 @@ | |||
*/ | |||
package org.sonar.api.batch.postjob.issue; | |||
import com.google.common.annotations.Beta; | |||
import javax.annotation.CheckForNull; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.rule.RuleKey; | |||
/** | |||
* Represents an issue state at the end of the batch analysis. Only available after local issue tracking in preview mode. | |||
* Represents an issue state at the end of the batch analysis. Some attributes are only available in preview/issues mode. | |||
* | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public interface Issue { | |||
public interface PostJobIssue { | |||
/** | |||
* Key of the issue. | |||
@@ -61,12 +59,6 @@ public interface Issue { | |||
@CheckForNull | |||
Integer line(); | |||
/** | |||
* Effort to fix the issue. Used by technical debt model. | |||
*/ | |||
@CheckForNull | |||
Double effortToFix(); | |||
/** | |||
* Message of the issue. | |||
*/ | |||
@@ -74,12 +66,12 @@ public interface Issue { | |||
String message(); | |||
/** | |||
* Severity. | |||
* Severity. Only accurate in preview/issues mode. | |||
*/ | |||
Severity severity(); | |||
/** | |||
* If the issue a new one. | |||
* If the issue a new one. Only available in preview/issues mode. | |||
*/ | |||
boolean isNew(); | |||
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.ExtensionPoint; | |||
import org.sonar.api.batch.BatchSide; | |||
@@ -27,15 +26,10 @@ import org.sonar.api.batch.BatchSide; | |||
* <p> | |||
* A sensor is invoked once for each module of a project, starting from leaf modules. The sensor can parse a flat file, connect to a web server... Sensors are | |||
* used to add measure and issues at file level. | |||
* | |||
* | |||
* <p> | |||
* For example the Cobertura Sensor parses Cobertura report and saves the first-level of measures on files. | |||
* | |||
* | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
@BatchSide | |||
@ExtensionPoint | |||
public interface Sensor { |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor; | |||
import com.google.common.annotations.Beta; | |||
import java.io.Serializable; | |||
import org.sonar.api.batch.fs.FileSystem; | |||
import org.sonar.api.batch.fs.InputModule; | |||
@@ -41,7 +40,6 @@ import org.sonar.api.utils.Version; | |||
* In order to write unit tests you can use {@link SensorContextTester} | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
public interface SensorContext { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputFile; | |||
/** | |||
@@ -28,7 +27,6 @@ import org.sonar.api.batch.fs.InputFile; | |||
* See {@link Sensor#describe(SensorDescriptor)} | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
public interface SensorDescriptor { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.coverage; | |||
import com.google.common.annotations.Beta; | |||
import com.google.common.collect.ImmutableSet; | |||
import java.util.Set; | |||
import org.sonar.api.measures.Metric; | |||
@@ -50,7 +49,6 @@ import static org.sonar.api.measures.CoreMetrics.UNCOVERED_LINES; | |||
* Different coverage categories. | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public enum CoverageType { | |||
UNIT(LINES_TO_COVER, UNCOVERED_LINES, COVERAGE_LINE_HITS_DATA, CONDITIONS_TO_COVER, UNCOVERED_CONDITIONS, COVERED_CONDITIONS_BY_LINE, CONDITIONS_BY_LINE), |
@@ -19,14 +19,12 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.coverage; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputFile; | |||
/** | |||
* This builder is used to define code coverage by tests of a given type (UT/IT/Overall) on files. | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public interface NewCoverage { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.cpd; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
@@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; | |||
* This builder is used to define tokens used by CPD algorithm on files. | |||
* @since 5.5 | |||
*/ | |||
@Beta | |||
public interface NewCpdTokens { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.highlighting; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
@@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; | |||
* This builder is used to define syntax highlighting (aka code coloration) on files. | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
public interface NewHighlighting { | |||
/** |
@@ -19,15 +19,12 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.highlighting; | |||
import com.google.common.annotations.Beta; | |||
/** | |||
* Experimental, do not use. | |||
* <br> | |||
* Possible types for highlighting code. See sonar-colorizer.css | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
public enum TypeOfText { | |||
ANNOTATION("a"), | |||
CONSTANT("c"), |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.issue; | |||
import com.google.common.annotations.Beta; | |||
import java.util.List; | |||
import javax.annotation.CheckForNull; | |||
import org.sonar.api.batch.rule.Severity; | |||
@@ -31,7 +30,6 @@ import org.sonar.api.rule.RuleKey; | |||
* | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
public interface Issue { | |||
interface Flow { |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.issue; | |||
import com.google.common.annotations.Beta; | |||
import javax.annotation.CheckForNull; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.fs.TextRange; | |||
@@ -29,7 +28,6 @@ import org.sonar.api.batch.fs.TextRange; | |||
* | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public interface IssueLocation { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.issue; | |||
import com.google.common.annotations.Beta; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
@@ -30,7 +29,6 @@ import org.sonar.api.rule.RuleKey; | |||
* | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
public interface NewIssue { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.issue; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
@@ -29,7 +28,6 @@ import org.sonar.api.batch.fs.TextRange; | |||
* | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public interface NewIssueLocation { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.measure; | |||
import com.google.common.annotations.Beta; | |||
import java.io.Serializable; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.measure.Metric; | |||
@@ -29,7 +28,6 @@ import org.sonar.api.batch.measure.Metric; | |||
* Should not be implemented by client. | |||
* @since 5.1 | |||
*/ | |||
@Beta | |||
public interface Measure<G extends Serializable> { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.measure; | |||
import com.google.common.annotations.Beta; | |||
import java.io.Serializable; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.measure.Metric; | |||
@@ -29,7 +28,6 @@ import org.sonar.api.batch.measure.Metric; | |||
* Should not be implemented by client. | |||
* @since 5.2 | |||
*/ | |||
@Beta | |||
public interface NewMeasure<G extends Serializable> { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.symbol; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
@@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; | |||
* This builder is used to define symbol references on files. | |||
* @since 5.6 | |||
*/ | |||
@Beta | |||
public interface NewSymbol { | |||
/** |
@@ -19,7 +19,6 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.symbol; | |||
import com.google.common.annotations.Beta; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
@@ -27,7 +26,6 @@ import org.sonar.api.batch.fs.TextRange; | |||
* This builder is used to define symbol references on files. | |||
* @since 5.6 | |||
*/ | |||
@Beta | |||
public interface NewSymbolTable { | |||
/** |
@@ -19,6 +19,10 @@ | |||
*/ | |||
package org.sonar.api.component; | |||
/** | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
public interface Module extends Component { | |||
String getDescription(); | |||
@@ -22,41 +22,14 @@ package org.sonar.api.component; | |||
import javax.annotation.CheckForNull; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.InputPath; | |||
import org.sonar.api.issue.Issuable; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.resources.Resource; | |||
import org.sonar.api.source.Highlightable; | |||
import org.sonar.api.source.Symbolizable; | |||
import org.sonar.api.test.TestPlan; | |||
import org.sonar.api.test.Testable; | |||
/** | |||
* Use this component to create perspective from resources or {@link InputPath} | |||
* Only on batch-side. | |||
* | |||
* <pre> | |||
* public class MySensor implements Sensor { | |||
* private final ResourcePerspectives perspectives; | |||
* | |||
* public MySensor(ResourcePerspectives perspectives) { | |||
* this.perspectives = perspectives; | |||
* } | |||
* | |||
* public void analyse(Project module, SensorContext context) { | |||
* // Get some Resource or InputFile/InputPath | |||
* Highlightable highlightable = perspectives.as(Highlightable.class, inputPath); | |||
* if (highlightable != null) { | |||
* ... | |||
* } | |||
* } | |||
* } | |||
* </pre> | |||
* @see Issuable | |||
* @see Highlightable | |||
* @see Symbolizable | |||
* @see Testable | |||
* @see TestPlan | |||
* @since 3.5 | |||
* @deprecated since 5.6 all features are available on {@link SensorContext} | |||
*/ | |||
@Deprecated | |||
public interface ResourcePerspectives { | |||
@CheckForNull |
@@ -19,13 +19,14 @@ | |||
*/ | |||
package org.sonar.api.component; | |||
import org.sonar.api.server.ServerSide; | |||
import javax.annotation.CheckForNull; | |||
import org.sonar.api.server.ServerSide; | |||
/** | |||
* @since 3.6 | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
@ServerSide | |||
public interface RubyComponentService { | |||
@@ -19,5 +19,9 @@ | |||
*/ | |||
package org.sonar.api.component; | |||
/** | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
public interface SourceFile extends Component { | |||
} |
@@ -21,6 +21,10 @@ package org.sonar.api.component.mock; | |||
import org.sonar.api.component.SourceFile; | |||
/** | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
public class MockSourceFile implements SourceFile { | |||
private String key; | |||
private String path; |
@@ -19,6 +19,7 @@ | |||
*/ | |||
package org.sonar.api.source; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.component.Perspective; | |||
import org.sonar.api.component.ResourcePerspectives; | |||
@@ -26,7 +27,9 @@ import org.sonar.api.component.ResourcePerspectives; | |||
* Use this perspective to save syntax highlighting on files. | |||
* See {@link ResourcePerspectives}. | |||
* @since 3.6 | |||
* @deprecated since 5.6 use {@link SensorContext#newHighlighting()} | |||
*/ | |||
@Deprecated | |||
public interface Highlightable extends Perspective { | |||
interface HighlightingBuilder { |
@@ -19,6 +19,12 @@ | |||
*/ | |||
package org.sonar.api.source; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
/** | |||
* @deprecated since 5.6 use {@link SensorContext#newSymbolTable()} | |||
*/ | |||
@Deprecated | |||
public interface Symbol { | |||
/** |
@@ -20,6 +20,7 @@ | |||
package org.sonar.api.source; | |||
import java.util.List; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.component.Perspective; | |||
import org.sonar.api.component.ResourcePerspectives; | |||
@@ -27,7 +28,9 @@ import org.sonar.api.component.ResourcePerspectives; | |||
* Use this perspective to save symbol references on files. | |||
* See {@link ResourcePerspectives}. | |||
* @since 3.6 | |||
* @deprecated since 5.6 use {@link SensorContext#newSymbolTable()} | |||
*/ | |||
@Deprecated | |||
public interface Symbolizable extends Perspective { | |||
interface SymbolTableBuilder { |
@@ -37,7 +37,9 @@ import org.codehaus.staxmate.in.SMHierarchicCursor; | |||
/** | |||
* @since 1.10 | |||
* @deprecated since 5.6 plugins should use their own dependencies | |||
*/ | |||
@Deprecated | |||
public class StaxParser { | |||
private SMInputFactory inf; | |||
@@ -77,7 +79,7 @@ public class StaxParser { | |||
} | |||
public void parse(File xmlFile) throws XMLStreamException { | |||
FileInputStream input=null; | |||
FileInputStream input = null; | |||
try { | |||
input = new FileInputStream(xmlFile); | |||
parse(input); | |||
@@ -123,7 +125,7 @@ public class StaxParser { | |||
if (StringUtils.startsWithIgnoreCase(undeclaredEntity, "u") && undeclaredEntity.length() == 5) { | |||
int unicodeCharHexValue = Integer.parseInt(undeclaredEntity.substring(1), 16); | |||
if (Character.isDefined(unicodeCharHexValue)) { | |||
undeclaredEntity = new String(new char[]{(char) unicodeCharHexValue}); | |||
undeclaredEntity = new String(new char[] {(char) unicodeCharHexValue}); | |||
} | |||
} | |||
return undeclaredEntity; |
@@ -21,7 +21,9 @@ package org.sonar.api.utils; | |||
/** | |||
* @since 1.10 | |||
* @deprecated since 5.6 | |||
*/ | |||
@Deprecated | |||
public class XmlParserException extends SonarException { | |||
public XmlParserException() { | |||
} |
@@ -56,7 +56,9 @@ import org.xml.sax.SAXException; | |||
* XML Parsing tool using XPATH. It's recommended to use StaxParser when parsing big XML files. | |||
* | |||
* @since 1.10 | |||
* @deprecated since 5.6 plugins should use their own dependencies | |||
*/ | |||
@Deprecated | |||
public class XpathParser { | |||
private static final String CAN_NOT_PARSE_XML = "can not parse xml : "; |
@@ -19,35 +19,29 @@ | |||
*/ | |||
package org.sonar.batch.postjob; | |||
import org.sonar.batch.issue.tracking.TrackedIssue; | |||
import com.google.common.base.Function; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Iterables; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.postjob.PostJobContext; | |||
import org.sonar.api.batch.postjob.issue.Issue; | |||
import org.sonar.api.batch.postjob.issue.PostJobIssue; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.batch.index.BatchComponent; | |||
import org.sonar.batch.index.BatchComponentCache; | |||
import org.sonar.batch.issue.IssueCache; | |||
import org.sonar.batch.issue.tracking.TrackedIssue; | |||
public class DefaultPostJobContext implements PostJobContext { | |||
private final Settings settings; | |||
private final AnalysisMode analysisMode; | |||
private final IssueCache cache; | |||
private final BatchComponentCache resourceCache; | |||
public DefaultPostJobContext(Settings settings, AnalysisMode analysisMode, IssueCache cache, BatchComponentCache resourceCache) { | |||
public DefaultPostJobContext(Settings settings, IssueCache cache, BatchComponentCache resourceCache) { | |||
this.settings = settings; | |||
this.analysisMode = analysisMode; | |||
this.cache = cache; | |||
this.resourceCache = resourceCache; | |||
} | |||
@@ -58,21 +52,16 @@ public class DefaultPostJobContext implements PostJobContext { | |||
} | |||
@Override | |||
public AnalysisMode analysisMode() { | |||
return analysisMode; | |||
} | |||
@Override | |||
public Iterable<Issue> issues() { | |||
public Iterable<PostJobIssue> issues() { | |||
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(false)), new IssueTransformer()); | |||
} | |||
@Override | |||
public Iterable<Issue> resolvedIssues() { | |||
public Iterable<PostJobIssue> resolvedIssues() { | |||
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(true)), new IssueTransformer()); | |||
} | |||
private class DefaultIssueWrapper implements Issue { | |||
private class DefaultIssueWrapper implements PostJobIssue { | |||
private final TrackedIssue wrapped; | |||
@@ -106,11 +95,6 @@ public class DefaultPostJobContext implements PostJobContext { | |||
return wrapped.startLine(); | |||
} | |||
@Override | |||
public Double effortToFix() { | |||
return wrapped.gap(); | |||
} | |||
@Override | |||
public String message() { | |||
return wrapped.getMessage(); | |||
@@ -128,9 +112,9 @@ public class DefaultPostJobContext implements PostJobContext { | |||
} | |||
} | |||
private class IssueTransformer implements Function<TrackedIssue, Issue> { | |||
private class IssueTransformer implements Function<TrackedIssue, PostJobIssue> { | |||
@Override | |||
public Issue apply(TrackedIssue input) { | |||
public PostJobIssue apply(TrackedIssue input) { | |||
return new DefaultIssueWrapper(input); | |||
} | |||
} |
@@ -22,7 +22,6 @@ package org.sonar.batch.postjob; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.BatchSide; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
import org.sonar.api.config.Settings; | |||
@@ -32,11 +31,9 @@ public class PostJobOptimizer { | |||
private static final Logger LOG = LoggerFactory.getLogger(PostJobOptimizer.class); | |||
private final Settings settings; | |||
private final AnalysisMode analysisMode; | |||
public PostJobOptimizer(Settings settings, AnalysisMode analysisMode) { | |||
public PostJobOptimizer(Settings settings) { | |||
this.settings = settings; | |||
this.analysisMode = analysisMode; | |||
} | |||
/** | |||
@@ -47,10 +44,6 @@ public class PostJobOptimizer { | |||
LOG.debug("'{}' skipped because one of the required properties is missing", descriptor.name()); | |||
return false; | |||
} | |||
if (descriptor.isDisabledInIssues() && analysisMode.isIssues()) { | |||
LOG.debug("'{}' skipped in issues mode", descriptor.name()); | |||
return false; | |||
} | |||
return true; | |||
} | |||
@@ -19,20 +19,18 @@ | |||
*/ | |||
package org.sonar.batch.postjob; | |||
import org.sonar.batch.issue.tracking.TrackedIssue; | |||
import java.util.Arrays; | |||
import org.junit.Before; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.postjob.issue.Issue; | |||
import org.sonar.api.batch.postjob.issue.PostJobIssue; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.resources.File; | |||
import org.sonar.batch.index.BatchComponentCache; | |||
import org.sonar.batch.issue.IssueCache; | |||
import org.sonar.batch.issue.tracking.TrackedIssue; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
@@ -41,7 +39,6 @@ public class DefaultPostJobContextTest { | |||
private IssueCache issueCache; | |||
private BatchComponentCache resourceCache; | |||
private AnalysisMode analysisMode; | |||
private DefaultPostJobContext context; | |||
private Settings settings; | |||
@@ -49,15 +46,13 @@ public class DefaultPostJobContextTest { | |||
public void prepare() { | |||
issueCache = mock(IssueCache.class); | |||
resourceCache = new BatchComponentCache(); | |||
analysisMode = mock(AnalysisMode.class); | |||
settings = new Settings(); | |||
context = new DefaultPostJobContext(settings, analysisMode, issueCache, resourceCache); | |||
context = new DefaultPostJobContext(settings, issueCache, resourceCache); | |||
} | |||
@Test | |||
public void test() { | |||
assertThat(context.settings()).isSameAs(settings); | |||
assertThat(context.analysisMode()).isSameAs(analysisMode); | |||
TrackedIssue defaultIssue = new TrackedIssue(); | |||
defaultIssue.setComponentKey("foo:src/Foo.php"); | |||
@@ -69,9 +64,8 @@ public class DefaultPostJobContextTest { | |||
defaultIssue.setSeverity("BLOCKER"); | |||
when(issueCache.all()).thenReturn(Arrays.asList(defaultIssue)); | |||
Issue issue = context.issues().iterator().next(); | |||
PostJobIssue issue = context.issues().iterator().next(); | |||
assertThat(issue.componentKey()).isEqualTo("foo:src/Foo.php"); | |||
assertThat(issue.effortToFix()).isEqualTo(2.0); | |||
assertThat(issue.isNew()).isTrue(); | |||
assertThat(issue.key()).isEqualTo("xyz"); | |||
assertThat(issue.line()).isEqualTo(1); |
@@ -23,13 +23,10 @@ import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.AnalysisMode; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
import org.sonar.api.config.Settings; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
public class PostJobOptimizerTest { | |||
@@ -38,13 +35,11 @@ public class PostJobOptimizerTest { | |||
private PostJobOptimizer optimizer; | |||
private Settings settings; | |||
private AnalysisMode analysisMode; | |||
@Before | |||
public void prepare() { | |||
settings = new Settings(); | |||
analysisMode = mock(AnalysisMode.class); | |||
optimizer = new PostJobOptimizer(settings, analysisMode); | |||
optimizer = new PostJobOptimizer(settings); | |||
} | |||
@Test | |||
@@ -63,15 +58,4 @@ public class PostJobOptimizerTest { | |||
settings.setProperty("sonar.foo.reportPath", "foo"); | |||
assertThat(optimizer.shouldExecute(descriptor)).isTrue(); | |||
} | |||
@Test | |||
public void should_disabled_in_issues_mode() { | |||
DefaultPostJobDescriptor descriptor = new DefaultPostJobDescriptor() | |||
.disabledInIssues(); | |||
assertThat(optimizer.shouldExecute(descriptor)).isTrue(); | |||
when(analysisMode.isIssues()).thenReturn(true); | |||
assertThat(optimizer.shouldExecute(descriptor)).isFalse(); | |||
} | |||
} |