From 34d71f5c14a0dec4679334adb054db2fc5d3fbbb Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 4 Apr 2024 14:12:14 +0200 Subject: [PATCH] Remove dead code --- .../api/batch/rule/internal/DefaultRule.java | 105 ------------------ .../batch/rule/internal/DefaultRuleParam.java | 47 -------- .../api/batch/rule/internal/NewRule.java | 86 -------------- .../api/batch/rule/internal/NewRuleParam.java | 36 ------ 4 files changed, 274 deletions(-) delete mode 100644 sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java delete mode 100644 sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java delete mode 100644 sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java delete mode 100644 sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRuleParam.java diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java deleted file mode 100644 index 02cf152a0d4..00000000000 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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.api.batch.rule.internal; - -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 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 params; - - public DefaultRule(NewRule newRule) { - this.key = newRule.key; - 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 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; - } - - @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 params() { - return params.values(); - } -} diff --git a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java deleted file mode 100644 index 50cd5db2f3e..00000000000 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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.api.batch.rule.internal; - -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; -import org.sonar.api.batch.rule.RuleParam; - -@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-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java deleted file mode 100644 index 660b31fa69b..00000000000 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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.api.batch.rule.internal; - -import java.util.HashMap; -import java.util.Map; -import javax.annotation.Nullable; -import org.apache.commons.lang3.ObjectUtils; -import org.apache.commons.lang3.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; - String name; - String description; - String severity = DEFAULT_SEVERITY; - String type; - String internalKey; - RuleStatus status = RuleStatus.defaultStatus(); - Map params = new HashMap<>(); - - public NewRule(RuleKey key) { - this.key = key; - } - - 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 = 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-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRuleParam.java b/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRuleParam.java deleted file mode 100644 index 81ce13e593e..00000000000 --- a/sonar-plugin-api-impl/src/main/java/org/sonar/api/batch/rule/internal/NewRuleParam.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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.api.batch.rule.internal; - -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; - } -} -- 2.39.5