diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2019-06-04 09:48:31 -0500 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-07-12 20:21:13 +0200 |
commit | be4e3879670cfe7c26bd1cfed28e29a7b20d2e2a (patch) | |
tree | 5ed538118878fb6c49698082a09b8f8b8775ec48 /sonar-scanner-engine/src/main | |
parent | e3a0108ef0dd26689dc58198e85ba8655c77fb1f (diff) | |
download | sonarqube-be4e3879670cfe7c26bd1cfed28e29a7b20d2e2a.tar.gz sonarqube-be4e3879670cfe7c26bd1cfed28e29a7b20d2e2a.zip |
Extract implementation from plugin API - Scanner rules
Diffstat (limited to 'sonar-scanner-engine/src/main')
14 files changed, 655 insertions, 8 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java index d8677af3bce..f0f8991c073 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ActiveRulesPublisher.java @@ -20,7 +20,7 @@ package org.sonar.scanner.report; import org.sonar.api.batch.rule.ActiveRules; -import org.sonar.api.batch.rule.internal.DefaultActiveRule; +import org.sonar.scanner.rule.DefaultActiveRule; import org.sonar.scanner.protocol.Constants; import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReportWriter; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesBuilder.java new file mode 100644 index 00000000000..ce5885836a2 --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesBuilder.java @@ -0,0 +1,49 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import org.sonar.api.batch.rule.ActiveRules; +import org.sonar.api.rule.RuleKey; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * Builds instances of {@link org.sonar.api.batch.rule.ActiveRules}. + * <b>For unit testing and internal use only</b>. + * + * @since 4.2 + */ +public class ActiveRulesBuilder { + + private final Map<RuleKey, NewActiveRule> map = new LinkedHashMap<>(); + + public ActiveRulesBuilder addRule(NewActiveRule newActiveRule) { + if (map.containsKey(newActiveRule.ruleKey)) { + throw new IllegalStateException(String.format("Rule '%s' is already activated", newActiveRule.ruleKey)); + } + map.put(newActiveRule.ruleKey, newActiveRule); + return this; + } + + public ActiveRules build() { + return new DefaultActiveRules(map.values()); + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java index d0cc5796176..f918a847f2b 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/ActiveRulesProvider.java @@ -27,8 +27,6 @@ import java.util.Map; import java.util.Set; import org.picocontainer.injectors.ProviderAdapter; import org.sonar.api.batch.rule.ActiveRules; -import org.sonar.api.batch.rule.internal.ActiveRulesBuilder; -import org.sonar.api.batch.rule.internal.NewActiveRule; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRule.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRule.java new file mode 100644 index 00000000000..68bdf1ed3af --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRule.java @@ -0,0 +1,101 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.concurrent.Immutable; +import org.sonar.api.batch.rule.ActiveRule; +import org.sonar.api.rule.RuleKey; + +@Immutable +public class DefaultActiveRule implements ActiveRule { + private final RuleKey ruleKey; + private final String severity; + private final String internalKey; + private final String language; + private final String templateRuleKey; + private final Map<String, String> params; + private final long createdAt; + private final long updatedAt; + private final String qProfileKey; + + DefaultActiveRule(NewActiveRule newActiveRule) { + this.severity = newActiveRule.severity; + this.internalKey = newActiveRule.internalKey; + this.templateRuleKey = newActiveRule.templateRuleKey; + this.ruleKey = newActiveRule.ruleKey; + this.params = Collections.unmodifiableMap(new HashMap<>(newActiveRule.params)); + this.language = newActiveRule.language; + this.createdAt = newActiveRule.createdAt; + this.updatedAt = newActiveRule.updatedAt; + this.qProfileKey = newActiveRule.qProfileKey; + } + + @Override + public RuleKey ruleKey() { + return ruleKey; + } + + @Override + public String severity() { + return severity; + } + + @Override + public String language() { + return language; + } + + @Override + public String param(String key) { + return params.get(key); + } + + @Override + public Map<String, String> params() { + // already immutable + return params; + } + + @Override + public String internalKey() { + return internalKey; + } + + @Override + public String templateRuleKey() { + return templateRuleKey; + } + + public long createdAt() { + return createdAt; + } + + public long updatedAt() { + return updatedAt; + } + + @Override + public String qpKey() { + return qProfileKey; + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRules.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRules.java new file mode 100644 index 00000000000..77a278772cc --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultActiveRules.java @@ -0,0 +1,83 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.annotation.concurrent.Immutable; +import org.sonar.api.batch.rule.ActiveRule; +import org.sonar.api.batch.rule.ActiveRules; +import org.sonar.api.rule.RuleKey; + +@Immutable +public class DefaultActiveRules implements ActiveRules { + private final Map<String, List<ActiveRule>> activeRulesByRepository = new HashMap<>(); + private final Map<String, Map<String, ActiveRule>> activeRulesByRepositoryAndKey = new HashMap<>(); + private final Map<String, Map<String, ActiveRule>> activeRulesByRepositoryAndInternalKey = new HashMap<>(); + private final Map<String, List<ActiveRule>> activeRulesByLanguage = new HashMap<>(); + + public DefaultActiveRules(Collection<NewActiveRule> newActiveRules) { + for (NewActiveRule newAR : newActiveRules) { + DefaultActiveRule ar = new DefaultActiveRule(newAR); + String repo = ar.ruleKey().repository(); + activeRulesByRepository.computeIfAbsent(repo, x -> new ArrayList<>()).add(ar); + if (ar.language() != null) { + activeRulesByLanguage.computeIfAbsent(ar.language(), x -> new ArrayList<>()).add(ar); + } + + activeRulesByRepositoryAndKey.computeIfAbsent(repo, r -> new HashMap<>()).put(ar.ruleKey().rule(), ar); + String internalKey = ar.internalKey(); + if (internalKey != null) { + activeRulesByRepositoryAndInternalKey.computeIfAbsent(repo, r -> new HashMap<>()).put(internalKey, ar); + } + } + } + + @Override + public ActiveRule find(RuleKey ruleKey) { + return activeRulesByRepositoryAndKey.getOrDefault(ruleKey.repository(), Collections.emptyMap()) + .get(ruleKey.rule()); + } + + @Override + public Collection<ActiveRule> findAll() { + return activeRulesByRepository.entrySet().stream().flatMap(x -> x.getValue().stream()).collect(Collectors.toList()); + } + + @Override + public Collection<ActiveRule> findByRepository(String repository) { + return activeRulesByRepository.getOrDefault(repository, Collections.emptyList()); + } + + @Override + public Collection<ActiveRule> findByLanguage(String language) { + return activeRulesByLanguage.getOrDefault(language, Collections.emptyList()); + } + + @Override + public ActiveRule findByInternalKey(String repository, String internalKey) { + return activeRulesByRepositoryAndInternalKey.containsKey(repository) ? activeRulesByRepositoryAndInternalKey.get(repository).get(internalKey) : null; + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRule.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRule.java new file mode 100644 index 00000000000..d53859ad348 --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRule.java @@ -0,0 +1,112 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.CheckForNull; +import javax.annotation.concurrent.Immutable; +import org.sonar.api.batch.rule.Rule; +import org.sonar.api.batch.rule.RuleParam; +import org.sonar.api.rule.RuleKey; +import org.sonar.api.rule.RuleStatus; + +@Immutable +public class DefaultRule implements Rule { + + private final RuleKey key; + private final Integer id; + private final String name; + private final String severity; + private final String type; + private final String description; + private final String internalKey; + private final RuleStatus status; + private final Map<String, RuleParam> params; + + DefaultRule(NewRule newRule) { + this.key = newRule.key; + this.id = newRule.id; + this.name = newRule.name; + this.severity = newRule.severity; + this.type = newRule.type; + this.description = newRule.description; + this.internalKey = newRule.internalKey; + this.status = newRule.status; + + Map<String, RuleParam> builder = new HashMap<>(); + for (NewRuleParam newRuleParam : newRule.params.values()) { + builder.put(newRuleParam.key, new DefaultRuleParam(newRuleParam)); + } + params = Collections.unmodifiableMap(builder); + } + + @Override + public RuleKey key() { + return key; + } + + @CheckForNull + public Integer id() { + return id; + } + + @Override + public String name() { + return name; + } + + @Override + public String severity() { + return severity; + } + + @CheckForNull + public String type() { + return type; + } + + @Override + public String description() { + return description; + } + + @Override + public String internalKey() { + return internalKey; + } + + @Override + public RuleStatus status() { + return status; + } + + @Override + public RuleParam param(String paramKey) { + return params.get(paramKey); + } + + @Override + public Collection<RuleParam> params() { + return params.values(); + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRuleParam.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRuleParam.java new file mode 100644 index 00000000000..31fed46d547 --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRuleParam.java @@ -0,0 +1,48 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import org.sonar.api.batch.rule.RuleParam; + +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; + +@Immutable +class DefaultRuleParam implements RuleParam { + + private final String key; + private final String description; + + DefaultRuleParam(NewRuleParam p) { + this.key = p.key; + this.description = p.description; + } + + @Override + public String key() { + return key; + } + + @Override + @Nullable + public String description() { + return description; + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRules.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRules.java index def001211e7..efcc7104b6e 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRules.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/DefaultRules.java @@ -17,7 +17,7 @@ * 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.rule.internal; +package org.sonar.scanner.rule; import java.util.ArrayList; import java.util.Collection; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewActiveRule.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewActiveRule.java new file mode 100644 index 00000000000..10867a5b29d --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewActiveRule.java @@ -0,0 +1,130 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.rule.RuleKey; +import org.sonar.api.rule.Severity; + +/** + * @since 4.2 + */ +@Immutable +public class NewActiveRule { + final RuleKey ruleKey; + final String name; + final String severity; + final Map<String, String> params; + final long createdAt; + final long updatedAt; + final String internalKey; + final String language; + final String templateRuleKey; + final String qProfileKey; + + NewActiveRule(Builder builder) { + this.ruleKey = builder.ruleKey; + this.name = builder.name; + this.severity = builder.severity; + this.params = builder.params; + this.createdAt = builder.createdAt; + this.updatedAt = builder.updatedAt; + this.internalKey = builder.internalKey; + this.language = builder.language; + this.templateRuleKey = builder.templateRuleKey; + this.qProfileKey = builder.qProfileKey; + } + + public static class Builder { + private RuleKey ruleKey; + private String name; + private String severity = Severity.defaultSeverity(); + private Map<String, String> params = new HashMap<>(); + private long createdAt; + private long updatedAt; + private String internalKey; + private String language; + private String templateRuleKey; + private String qProfileKey; + + public Builder setRuleKey(RuleKey ruleKey) { + this.ruleKey = ruleKey; + return this; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setSeverity(@Nullable String severity) { + this.severity = StringUtils.defaultIfBlank(severity, Severity.defaultSeverity()); + return this; + } + + public Builder setParam(String key, @Nullable String value) { + // possible improvement : check that the param key exists in rule definition + if (value == null) { + params.remove(key); + } else { + params.put(key, value); + } + return this; + } + + public Builder setCreatedAt(long createdAt) { + this.createdAt = createdAt; + return this; + } + + public Builder setUpdatedAt(long updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public Builder setInternalKey(@Nullable String internalKey) { + this.internalKey = internalKey; + return this; + } + + public Builder setLanguage(@Nullable String language) { + this.language = language; + return this; + } + + public Builder setTemplateRuleKey(@Nullable String templateRuleKey) { + this.templateRuleKey = templateRuleKey; + return this; + } + + public Builder setQProfileKey(String qProfileKey) { + this.qProfileKey = qProfileKey; + return this; + } + + public NewActiveRule build() { + return new NewActiveRule(this); + } + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewRule.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewRule.java new file mode 100644 index 00000000000..179768d1c7b --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewRule.java @@ -0,0 +1,92 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nullable; +import org.apache.commons.lang.ObjectUtils; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.rule.RuleKey; +import org.sonar.api.rule.RuleStatus; +import org.sonar.api.rule.Severity; + +public class NewRule { + + private static final String DEFAULT_SEVERITY = Severity.defaultSeverity(); + + final RuleKey key; + Integer id; + String name; + String description; + String severity = DEFAULT_SEVERITY; + String type; + String internalKey; + RuleStatus status = RuleStatus.defaultStatus(); + Map<String, NewRuleParam> params = new HashMap<>(); + + public NewRule(RuleKey key) { + this.key = key; + } + + public NewRule setId(@Nullable Integer id) { + this.id = id; + return this; + } + + public NewRule setDescription(@Nullable String description) { + this.description = description; + return this; + } + + public NewRule setName(@Nullable String s) { + this.name = s; + return this; + } + + public NewRule setSeverity(@Nullable String severity) { + this.severity = StringUtils.defaultIfBlank(severity, DEFAULT_SEVERITY); + return this; + } + + public NewRule setType(@Nullable String type) { + this.type = type; + return this; + } + + public NewRule setStatus(@Nullable RuleStatus s) { + this.status = (RuleStatus) ObjectUtils.defaultIfNull(s, RuleStatus.defaultStatus()); + return this; + } + + public NewRule setInternalKey(@Nullable String s) { + this.internalKey = s; + return this; + } + + public NewRuleParam addParam(String paramKey) { + if (params.containsKey(paramKey)) { + throw new IllegalStateException(String.format("Parameter '%s' already exists on rule '%s'", paramKey, key)); + } + NewRuleParam param = new NewRuleParam(paramKey); + params.put(paramKey, param); + return param; + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewRuleParam.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewRuleParam.java new file mode 100644 index 00000000000..9fa482553c5 --- /dev/null +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/NewRuleParam.java @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program 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. + * + * This program 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.scanner.rule; + +import javax.annotation.Nullable; + +public class NewRuleParam { + final String key; + String description; + + NewRuleParam(String key) { + this.key = key; + } + + public NewRuleParam setDescription(@Nullable String s) { + description = s; + return this; + } +} diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesBuilder.java index f7ebe363d09..3d1ccb33db5 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesBuilder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesBuilder.java @@ -17,7 +17,7 @@ * 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.rule.internal; +package org.sonar.scanner.rule; import org.sonar.api.batch.rule.Rules; import org.sonar.api.rule.RuleKey; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesProvider.java index cb7bff1bb40..a0c89c2d6f0 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RulesProvider.java @@ -22,8 +22,6 @@ package org.sonar.scanner.rule; import java.util.List; import org.picocontainer.injectors.ProviderAdapter; import org.sonar.api.batch.rule.Rules; -import org.sonar.api.batch.rule.internal.NewRule; -import org.sonar.api.batch.rule.internal.RulesBuilder; import org.sonar.api.rule.RuleKey; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/SensorContextTester.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/SensorContextTester.java index 6e81544e146..21e5a8271ca 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/SensorContextTester.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/SensorContextTester.java @@ -44,7 +44,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule; import org.sonar.api.batch.fs.internal.DefaultInputProject; import org.sonar.api.batch.fs.internal.DefaultTextPointer; import org.sonar.api.batch.rule.ActiveRules; -import org.sonar.api.batch.rule.internal.ActiveRulesBuilder; +import org.sonar.scanner.rule.ActiveRulesBuilder; import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.code.NewSignificantCode; |