--- /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.languages;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+public final class Language {
+
+ private final String key, name;
+ private final String[] fileSuffixes;
+
+ public Language(String key, String name, String... fileSuffixes) {
+ this.key = key;
+ this.name = name;
+ this.fileSuffixes = fileSuffixes;
+ }
+
+ /**
+ * For example "java".
+ */
+ public String key() {
+ return key;
+ }
+
+ /**
+ * For example "Java"
+ */
+ public String name() {
+ return name;
+ }
+
+ /**
+ * For example ["jav", "java"].
+ */
+ public Collection<String> fileSuffixes() {
+ return Arrays.asList(fileSuffixes);
+ }
+
+}
--- /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.
+ */
+@javax.annotation.ParametersAreNonnullByDefault
+package org.sonar.api.batch.languages;
\ No newline at end of file
}
@Override
- public Measure getMeasure(Resource resource, org.sonar.api.batch.measures.Metric<?> metric) {
+ public Measure getMeasure(Resource resource, org.sonar.api.batch.measure.Metric<?> metric) {
return getMeasures(resource, MeasuresFilters.metric(metric));
}
*/
package org.sonar.batch.scan;
+import org.sonar.api.batch.measure.Metric;
+
import org.sonar.api.batch.SensorContext;
import org.sonar.api.batch.analyzer.AnalyzerContext;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssue;
import org.sonar.api.batch.analyzer.measure.internal.DefaultAnalyzerMeasureBuilder;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.config.Settings;
*/
package org.sonar.batch.scan;
+import org.sonar.api.batch.measure.Metric;
+
import org.sonar.api.batch.DependedUpon;
import org.sonar.api.batch.DependsUpon;
import org.sonar.api.batch.Sensor;
import org.sonar.api.batch.analyzer.AnalyzerContext;
import org.sonar.api.batch.analyzer.internal.DefaultAnalyzerDescriptor;
import org.sonar.api.batch.fs.FileSystem;
-import org.sonar.api.batch.measures.Metric;
import org.sonar.api.resources.Project;
import org.sonar.batch.scan2.AnalyzerOptimizer;
*/
package org.sonar.batch.scan2;
+import org.sonar.api.batch.measure.Metric;
+
import org.sonar.api.batch.analyzer.AnalyzerContext;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssue;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssueBuilder;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.config.Settings;
import org.sonar.api.issue.internal.DefaultIssue;
public abstract Resource addResource(Resource resource);
@CheckForNull
- public abstract Measure getMeasure(Resource resource, org.sonar.api.batch.measures.Metric<?> metric);
+ public abstract Measure getMeasure(Resource resource, org.sonar.api.batch.measure.Metric<?> metric);
@CheckForNull
public abstract <M> M getMeasures(Resource resource, MeasuresFilter<M> filter);
*/
package org.sonar.api.batch.analyzer;
+import com.google.common.annotations.Beta;
import org.sonar.api.BatchExtension;
/**
*
* @since 4.4
*/
+@Beta
public interface Analyzer extends BatchExtension {
/**
*/
package org.sonar.api.batch.analyzer;
+import org.sonar.api.batch.measure.Metric;
+
+import com.google.common.annotations.Beta;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssue;
import org.sonar.api.batch.analyzer.issue.AnalyzerIssueBuilder;
import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure;
import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.config.Settings;
/**
* @since 4.4
*/
+@Beta
public interface AnalyzerContext {
/**
*/
package org.sonar.api.batch.analyzer;
+import org.sonar.api.batch.measure.Metric;
+
+import com.google.common.annotations.Beta;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.languages.Language;
-import org.sonar.api.batch.measures.Metric;
/**
* Describe what an {@link Analyzer} is doing. Information may be used by the platform
* to log interesting information or perform some optimization.
* @since 4.4
*/
+@Beta
public interface AnalyzerDescriptor {
/**
AnalyzerDescriptor provides(Metric<?>... metrics);
/**
- * List {@link Language} this {@link Analyzer} work on. May be used by the platform to skip execution of the {@link Analyzer} when
+ * List languages this {@link Analyzer} work on. May be used by the platform to skip execution of the {@link Analyzer} when
* no file for given languages are present in the project.
* If no language is provided then it will be executed for all languages.
*/
*/
package org.sonar.api.batch.analyzer.internal;
+import org.sonar.api.batch.measure.Metric;
+
import org.sonar.api.batch.analyzer.AnalyzerDescriptor;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import java.util.Arrays;
import java.util.Collection;
*/
package org.sonar.api.batch.analyzer.issue;
+import com.google.common.annotations.Beta;
import org.sonar.api.batch.analyzer.Analyzer;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.rule.RuleKey;
*
* @since 4.4
*/
+@Beta
public interface AnalyzerIssue {
/**
*/
package org.sonar.api.batch.analyzer.issue;
+import com.google.common.annotations.Beta;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.rule.RuleKey;
*
* @since 4.4
*/
+@Beta
public interface AnalyzerIssueBuilder {
/**
*/
package org.sonar.api.batch.analyzer.measure;
+import org.sonar.api.batch.measure.Metric;
+
+import com.google.common.annotations.Beta;
import org.sonar.api.batch.analyzer.Analyzer;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import javax.annotation.Nullable;
* A measure computed by an {@link Analyzer}.
* @since 4.4
*/
+@Beta
public interface AnalyzerMeasure<G extends Serializable> {
/**
*/
package org.sonar.api.batch.analyzer.measure;
+import org.sonar.api.batch.measure.Metric;
+
+import com.google.common.annotations.Beta;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import java.io.Serializable;
* Builder to create new {@link AnalyzerMeasure}
* @since 4.4
*/
+@Beta
public interface AnalyzerMeasureBuilder<G extends Serializable> {
/**
*/
package org.sonar.api.batch.analyzer.measure.internal;
+import org.sonar.api.batch.measure.Metric;
+
import com.google.common.base.Preconditions;
import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import javax.annotation.Nullable;
DefaultAnalyzerMeasure(DefaultAnalyzerMeasureBuilder<G> builder) {
Preconditions.checkNotNull(builder.value, "Measure value can't be null");
- Preconditions.checkNotNull(builder.metric, "Measure metricKey can't be null");
+ Preconditions.checkNotNull(builder.metric, "Measure metric can't be null");
+ Preconditions.checkState(builder.metric.valueType().equals(builder.value.getClass()), "Measure value should be of type " + builder.metric.valueType());
this.inputFile = builder.file;
this.metric = builder.metric;
this.value = builder.value;
*/
package org.sonar.api.batch.analyzer.measure.internal;
+import org.sonar.api.batch.measure.Metric;
+
import com.google.common.base.Preconditions;
import org.sonar.api.batch.analyzer.measure.AnalyzerMeasure;
import org.sonar.api.batch.analyzer.measure.AnalyzerMeasureBuilder;
import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measures.Metric;
import java.io.Serializable;
+++ /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.languages;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-public final class Language {
-
- private final String key, name;
- private final String[] fileSuffixes;
-
- public Language(String key, String name, String... fileSuffixes) {
- this.key = key;
- this.name = name;
- this.fileSuffixes = fileSuffixes;
- }
-
- /**
- * For example "java".
- */
- public String key() {
- return key;
- }
-
- /**
- * For example "Java"
- */
- public String name() {
- return name;
- }
-
- /**
- * For example ["jav", "java"].
- */
- public Collection<String> fileSuffixes() {
- return Arrays.asList(fileSuffixes);
- }
-
-}
+++ /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.
- */
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.languages;
\ No newline at end of file
--- /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.measure;
+
+import com.google.common.annotations.Beta;
+
+import java.io.Serializable;
+
+/**
+ * Metric definition.
+ * @since 4.4
+ */
+@Beta
+public interface Metric<G extends Serializable> {
+
+ String key();
+
+ Class<G> valueType();
+
+}
--- /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.
+ */
+@javax.annotation.ParametersAreNonnullByDefault
+package org.sonar.api.batch.measure;
\ No newline at end of file
+++ /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.measures;
-
-import java.io.Serializable;
-
-public interface Metric<G extends Serializable> {
-
- Class<G> type();
-
- String key();
-}
+++ /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.
- */
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.api.batch.measures;
\ No newline at end of file
};
}
- public static MeasuresFilter<Measure> metric(final org.sonar.api.batch.measures.Metric<?> metric) {
+ public static MeasuresFilter<Measure> metric(final org.sonar.api.batch.measure.Metric<?> metric) {
return metric(metric.key());
}
@Table(name = "metrics")
@Entity(name = "Metric")
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
-public class Metric<G extends Serializable> implements ServerExtension, BatchExtension, Serializable, org.sonar.api.batch.measures.Metric<G> {
+public class Metric<G extends Serializable> implements ServerExtension, BatchExtension, Serializable, org.sonar.api.batch.measure.Metric<G> {
/**
* A metric bigger value means a degradation
RATING(String.class),
WORK_DUR(Long.class);
- private final Class measureJavaType;
+ private final Class valueType;
private ValueType(Class measureJavaType) {
- this.measureJavaType = measureJavaType;
+ this.valueType = measureJavaType;
}
- private Class measureJavaType() {
- return measureJavaType;
+ private Class valueType() {
+ return valueType;
}
}
}
@Override
- public Class<G> type() {
- return getType().measureJavaType();
+ public Class<G> valueType() {
+ return getType().valueType();
}
}