*/
package org.sonar.xoo.lang;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.dependency.Dependency;
import org.sonar.api.batch.sensor.dependency.internal.DefaultDependency;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
*/
package org.sonar.xoo.lang;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.apache.commons.io.FileUtils;
import org.junit.Before;
import org.junit.Rule;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
import org.sonar.api.measures.CoreMetrics;
*/
package org.sonar.xoo.rule;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor;
import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.issue.Issue.Severity;
*/
package org.sonar.batch.deprecated;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.config.Settings;
import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.dependency.NewDependency;
import org.sonar.api.batch.sensor.dependency.internal.DefaultDependency;
import org.sonar.api.batch.sensor.duplication.NewDuplication;
import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
-import org.sonar.api.batch.sensor.issue.Issue;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+import org.sonar.api.batch.sensor.issue.NewIssue;
import org.sonar.api.batch.sensor.issue.internal.DefaultIssue;
import org.sonar.api.batch.sensor.measure.NewMeasure;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
}
@Override
- public Issue newIssue() {
+ public NewIssue newIssue() {
return new DefaultIssue(sensorStorage);
}
*/
package org.sonar.batch.sensor;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import com.google.common.base.Preconditions;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.rule.ActiveRules;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.duplication.Duplication;
import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
import org.sonar.api.batch.sensor.issue.Issue;
*/
package org.sonar.batch.cpd;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.stubbing.Answer;
import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.duplication.NewDuplication;
import org.sonar.api.batch.sensor.duplication.internal.DefaultDuplication;
import org.sonar.api.batch.sensor.measure.Measure;
*/
package org.sonar.batch.sensor;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.config.Settings;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.batch.index.ComponentDataCache;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.sonar.api.batch.sensor.duplication.NewDuplication;
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
import org.sonar.api.batch.sensor.issue.Issue;
+import org.sonar.api.batch.sensor.issue.NewIssue;
import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.batch.sensor.measure.NewMeasure;
import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
// ----------- ISSUES --------------
/**
- * Fluent builder to create a new {@link Issue}. Don't forget to call {@link Issue#save()} once all parameters are provided.
+ * Fluent builder to create a new {@link Issue}. Don't forget to call {@link NewIssue#save()} once all parameters are provided.
*/
- Issue newIssue();
+ NewIssue newIssue();
// ------------ HIGHLIGHTING ------------
+++ /dev/null
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.batch.sensor;
-
-import org.sonar.api.batch.sensor.dependency.Dependency;
-import org.sonar.api.batch.sensor.duplication.Duplication;
-import org.sonar.api.batch.sensor.issue.Issue;
-import org.sonar.api.batch.sensor.measure.Measure;
-
-/**
- * Interface for storing data computed by sensors.
- * @since 5.1
- */
-public interface SensorStorage {
-
- void store(Measure measure);
-
- void store(Issue issue);
-
- void store(Duplication duplication);
-
- void store(Dependency dependency);
-
-}
*/
package org.sonar.api.batch.sensor.dependency.internal;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import com.google.common.base.Preconditions;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.dependency.Dependency;
import org.sonar.api.batch.sensor.dependency.NewDependency;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
*/
package org.sonar.api.batch.sensor.duplication.internal;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import com.google.common.base.Preconditions;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.duplication.Duplication;
import org.sonar.api.batch.sensor.duplication.NewDuplication;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
import javax.annotation.Nullable;
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.batch.sensor.internal;
+
+import org.sonar.api.batch.sensor.dependency.Dependency;
+import org.sonar.api.batch.sensor.duplication.Duplication;
+import org.sonar.api.batch.sensor.issue.Issue;
+import org.sonar.api.batch.sensor.measure.Measure;
+
+/**
+ * Interface for storing data computed by sensors.
+ * @since 5.1
+ */
+public interface SensorStorage {
+
+ void store(Measure measure);
+
+ void store(Issue issue);
+
+ void store(Duplication duplication);
+
+ void store(Dependency dependency);
+
+}
*/
package org.sonar.api.batch.sensor.issue;
-import com.google.common.annotations.Beta;
-import org.sonar.api.batch.fs.InputDir;
-import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputPath;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.rule.RuleKey;
import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
/**
* Represents an issue detected by a {@link Sensor}.
*
- * @since 5.0
+ * @since 5.1
*/
-@Beta
public interface Issue {
public enum Severity {
BLOCKER;
}
- /**
- * The {@link RuleKey} of the issue.
- */
- Issue ruleKey(RuleKey ruleKey);
-
/**
* The {@link RuleKey} of this issue.
*/
RuleKey ruleKey();
- /**
- * The {@link InputFile} the issue belongs to. For global issues call {@link #onProject()}.
- */
- Issue onFile(InputFile file);
-
- /**
- * The {@link InputDir} the issue belongs to. For global issues call {@link #onProject()}.
- */
- Issue onDir(InputDir inputDir);
-
- /**
- * Tell that the issue is global to the project.
- */
- Issue onProject();
-
/**
* The {@link InputPath} this issue belongs to. Returns null if issue is global to the project.
*/
@CheckForNull
InputPath inputPath();
- /**
- * Line of the issue. Only available for {@link #onFile(InputFile)} issues.
- * If no line is specified it means that issue is global to the file.
- */
- Issue atLine(int line);
-
/**
* Line of the issue. Null for global issues and issues on directories. Can also be null
* for files (issue global to the file).
@CheckForNull
Integer line();
- /**
- * Effort to fix the issue.
- */
- Issue effortToFix(@Nullable Double effortToFix);
-
/**
* Effort to fix the issue. Used by technical debt model.
*/
@CheckForNull
Double effortToFix();
- /**
- * Message of the issue.
- */
- Issue message(String message);
-
/**
* Message of the issue.
*/
@CheckForNull
String message();
- /**
- * Override severity of the issue.
- * Setting a null value or not calling this method means to use severity configured in quality profile.
- */
- Issue overrideSeverity(@Nullable Severity severity);
-
/**
* Overriden severity.
*/
@CheckForNull
Severity overridenSeverity();
- /**
- * Save the issue. If rule key is unknow or rule not enabled in the current quality profile then a warning is logged but no exception
- * is thrown.
- */
- void save();
-
}
--- /dev/null
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.batch.sensor.issue;
+
+import org.sonar.api.batch.fs.InputDir;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.sensor.Sensor;
+import org.sonar.api.batch.sensor.issue.Issue.Severity;
+import org.sonar.api.rule.RuleKey;
+
+import javax.annotation.Nullable;
+
+/**
+ * Represents an issue detected by a {@link Sensor}.
+ *
+ * @since 5.1
+ */
+public interface NewIssue {
+
+ /**
+ * The {@link RuleKey} of the issue.
+ */
+ NewIssue ruleKey(RuleKey ruleKey);
+
+ /**
+ * The {@link InputFile} the issue belongs to. For global issues call {@link #onProject()}.
+ */
+ NewIssue onFile(InputFile file);
+
+ /**
+ * The {@link InputDir} the issue belongs to. For global issues call {@link #onProject()}.
+ */
+ NewIssue onDir(InputDir inputDir);
+
+ /**
+ * Tell that the issue is global to the project.
+ */
+ NewIssue onProject();
+
+ /**
+ * Line of the issue. Only available for {@link #onFile(InputFile)} issues.
+ * If no line is specified it means that issue is global to the file.
+ */
+ NewIssue atLine(int line);
+
+ /**
+ * Effort to fix the issue.
+ */
+ NewIssue effortToFix(@Nullable Double effortToFix);
+
+ /**
+ * Message of the issue.
+ */
+ NewIssue message(String message);
+
+ /**
+ * Override severity of the issue.
+ * Setting a null value or not calling this method means to use severity configured in quality profile.
+ */
+ NewIssue overrideSeverity(@Nullable Severity severity);
+
+ /**
+ * Save the issue. If rule key is unknown or rule not enabled in the current quality profile then a warning is logged but no exception
+ * is thrown.
+ */
+ void save();
+
+}
*/
package org.sonar.api.batch.sensor.issue.internal;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.InputPath;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
import org.sonar.api.batch.sensor.issue.Issue;
+import org.sonar.api.batch.sensor.issue.NewIssue;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.utils.internal.Uuids;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-public class DefaultIssue extends DefaultStorable implements Issue {
+public class DefaultIssue extends DefaultStorable implements Issue, NewIssue {
private static final String INPUT_DIR_SHOULD_BE_NON_NULL = "InputDir should be non null";
private static final String INPUT_FILE_SHOULD_BE_NON_NULL = "InputFile should be non null";
}
@Override
- public Issue overrideSeverity(@Nullable Severity severity) {
+ public DefaultIssue overrideSeverity(@Nullable Severity severity) {
this.overridenSeverity = severity;
return this;
}
*/
package org.sonar.api.batch.sensor.measure.internal;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import com.google.common.base.Preconditions;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.measure.Metric;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.batch.sensor.measure.NewMeasure;
*/
package org.sonar.api.batch.sensor.issue.internal;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.rule.RuleKey;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
*/
package org.sonar.api.batch.sensor.measure.internal;
+import org.sonar.api.batch.sensor.internal.SensorStorage;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.SensorStorage;
import org.sonar.api.measures.CoreMetrics;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;