* A pre-implementation of the CpdMapping extension point
*
* @since 1.10
- * @deprecated since 5.6
+ * @deprecated since 5.6 use {@link SensorContext#newCpdTokens()}
*/
@Deprecated
public abstract class AbstractCpdMapping implements CpdMapping {
* </ul>
*
* @since 2.3
- * @deprecated since 5.6 no more used since Decorators are deprecated
+ * @deprecated since 5.6 as {@link Decorator} is deprecated
*/
@Deprecated
public interface DecoratorBarriers {
/**
* @since 1.10
- * @deprecated since 5.6 no more used since Decorator is deprecated
+ * @deprecated since 5.6 as {@link Decorator} is deprecated
*/
@Deprecated
public interface DecoratorContext {
* it is an asynchronous processing on server side.
*
* @since 1.10
- * @deprecated since 5.6 use {@link org.sonar.api.batch.postjob.PostJob}
+ * @deprecated since 5.6 use org.sonar.api.batch.postjob.PostJob
*/
@Deprecated
@BatchSide
*
*
* @since 1.10
- * @deprecated since 5.6 use {@link org.sonar.api.batch.sensor.Sensor}
+ * @deprecated since 5.6 use org.sonar.api.batch.sensor.Sensor
*/
@Deprecated
@BatchSide
* @since 5.2
* @see InputFile
* @see InputDir
+ * @see InputModule
*/
public interface InputComponent {
import java.nio.file.Path;
/**
- * Layer over {@link java.io.File} for directories.
+ * Layer over {@link java.io.File} for directories. You can access InputDir using {@link FileSystem#inputDir(File)}.
*
* @since 4.5
*/
*/
package org.sonar.api.batch.fs;
+import org.sonar.api.batch.sensor.SensorContext;
+
/**
- * Used to create issues and measures on modules.
+ * Used to create issues and measures on modules. You can access InputModule using {@link SensorContext#module()}
*
* @since 5.2
*/
*/
package org.sonar.api.batch.postjob;
+import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.postjob.issue.PostJobIssue;
import org.sonar.api.config.Settings;
*/
Settings settings();
+ AnalysisMode analysisMode();
+
// ----------- Only available in preview mode --------------
/**
- * All the unresolved issues of the project, including the issues reported by end-users.
+ * All the unresolved issues of the project, including the issues reported by end-users. Only available in preview/issues mode.
+ * @throw {@link UnsupportedOperationException} if not in preview/issues mode. To test the mode you can use {@link #analysisMode()}.
*/
Iterable<PostJobIssue> issues();
/**
- * All the issues of this project that have been marked as resolved during this scan
+ * All the issues of this project that have been marked as resolved during this scan. Only available in preview/issues mode.
+ * @throw {@link UnsupportedOperationException} if not in preview mode. To test the mode you can use {@link #analysisMode()}.
*/
Iterable<PostJobIssue> resolvedIssues();
import org.sonar.api.rule.RuleKey;
/**
- * Represents an issue state at the end of the batch analysis. Some attributes are only available in preview/issues mode.
+ * Represents an issue state at the end of the scanner analysis in preview/issues mode.
*
* @since 5.2
*/
String message();
/**
- * Severity. Only accurate in preview/issues mode.
+ * Severity.
*/
Severity severity();
/**
- * If the issue a new one. Only available in preview/issues mode.
+ * If the issue a new one.
*/
boolean isNew();
/**
* @since 3.6
- * @deprecated since 5.6
*/
-@Deprecated
@ServerSide
public interface RubyComponentService {
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.sonar.api.batch.fs.FileSystem;
+import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.WildcardPattern;
/**
* @since 1.10
- * @deprecated since 5.6 should not be used in any API
+ * @deprecated since 5.6 replaced by {@link InputDir}.
*/
@Deprecated
public class Directory extends Resource {
import org.apache.commons.lang.builder.ToStringBuilder;
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.fs.FileSystem;
+import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.WildcardPattern;
/**
- * This class is an implementation of a resource of type FILE
- *
* @since 1.10
- * @deprecated since 5.6 should not be used in any API
+ * @deprecated since 5.6 replaced by {@link InputFile}.
*/
@Deprecated
public class File extends Resource {
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.sonar.api.CoreProperties;
+import org.sonar.api.batch.fs.InputModule;
import org.sonar.api.component.Component;
import org.sonar.api.config.Settings;
/**
- * A class that manipulates Projects in the Sonar way.
- *
* @since 1.10
- * @deprecated since 5.6 should not be used in any API
+ * @deprecated since 5.6 replaced by {@link InputModule}.
*/
@Deprecated
public class Project extends Resource implements Component {
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.apache.commons.lang.StringUtils;
+import org.sonar.api.batch.fs.InputComponent;
/**
- * The interface to implement to create a resource in Sonar
- *
* @since 1.10
- * @deprecated since 5.6 should not be used in any API
+ * @deprecated since 5.6 replaced by {@link InputComponent}
*/
@Deprecated
public abstract class Resource implements Serializable {
/**
* @since 1.10
- * @deprecated since 5.6 should not be used in any API
+ * @deprecated since 5.6 as {@link Resource} is deprecated
*/
@Deprecated
public final class ResourceUtils {
import java.util.List;
/**
- * @deprecated since 5.6 feature will be removed soon
+ * @deprecated since 5.6. Feature will be removed without any alternatives.
*/
@Deprecated
public interface CoverageBlock {
import org.sonar.api.batch.fs.InputFile;
/**
- * @deprecated since 5.6 feature will be removed soon
+ * @deprecated since 5.6. Feature will be removed without any alternatives.
*/
@Deprecated
public interface MutableTestCase extends TestCase {
package org.sonar.api.test;
/**
- * @deprecated since 5.6 feature will be removed soon
+ * @deprecated since 5.6. Feature will be removed without any alternatives.
*/
@Deprecated
public interface MutableTestPlan extends TestPlan<MutableTestCase> {
package org.sonar.api.test;
/**
- * @deprecated since 5.6 feature will be removed soon
+ * @deprecated since 5.6. Feature will be removed without any alternatives.
*/
@Deprecated
public interface MutableTestable extends Testable {
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.PostJobIssue;
private final Settings settings;
private final IssueCache cache;
private final BatchComponentCache resourceCache;
+ private final AnalysisMode analysisMode;
- public DefaultPostJobContext(Settings settings, IssueCache cache, BatchComponentCache resourceCache) {
+ public DefaultPostJobContext(Settings settings, IssueCache cache, BatchComponentCache resourceCache, AnalysisMode analysisMode) {
this.settings = settings;
this.cache = cache;
this.resourceCache = resourceCache;
+ this.analysisMode = analysisMode;
}
@Override
return settings;
}
+ @Override
+ public AnalysisMode analysisMode() {
+ return analysisMode;
+ }
+
@Override
public Iterable<PostJobIssue> issues() {
+ if (!analysisMode.isIssues()) {
+ throw new UnsupportedOperationException("Issues are only available to PostJobs in 'issues' mode.");
+ }
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(false)), new IssueTransformer());
}
@Override
public Iterable<PostJobIssue> resolvedIssues() {
+ if (!analysisMode.isIssues()) {
+ throw new UnsupportedOperationException("Resolved issues are only available to PostJobs in 'issues' mode.");
+ }
return Iterables.transform(Iterables.filter(cache.all(), new ResolvedPredicate(true)), new IssueTransformer());
}
@Override
public Severity severity() {
- String severity = wrapped.severity();
- return severity != null ? Severity.valueOf(severity) : null;
+ return Severity.valueOf(wrapped.severity());
}
@Override
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.PostJobIssue;
import org.sonar.api.batch.rule.Severity;
private BatchComponentCache resourceCache;
private DefaultPostJobContext context;
private Settings settings;
+ private AnalysisMode analysisMode;
@Before
public void prepare() {
issueCache = mock(IssueCache.class);
resourceCache = new BatchComponentCache();
settings = new Settings();
- context = new DefaultPostJobContext(settings, issueCache, resourceCache);
+ analysisMode = mock(AnalysisMode.class);
+ context = new DefaultPostJobContext(settings, issueCache, resourceCache, analysisMode);
}
@Test
- public void test() {
+ public void testIssues() {
+ when(analysisMode.isIssues()).thenReturn(true);
+
assertThat(context.settings()).isSameAs(settings);
TrackedIssue defaultIssue = new TrackedIssue();