From 4b54d70424c0ce23f45c6cac028986b8718b135c Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Tue, 14 Jun 2016 17:44:48 +0200 Subject: [PATCH] SONAR-7727 Remove CheckFactory and AnnotationCheckFactory --- .../api/checks/AnnotationCheckFactory.java | 173 --------------- .../org/sonar/api/checks/CheckFactory.java | 73 ------- .../org/sonar/api/checks/package-info.java | 23 -- .../org/sonar/api/checks/AbstractCheck.java | 32 --- .../checks/AnnotationCheckFactoryTest.java | 199 ------------------ .../api/checks/CheckWithIntegerProperty.java | 35 --- .../org/sonar/api/checks/CheckWithKey.java | 28 --- .../CheckWithOverriddenPropertyKey.java | 35 --- .../checks/CheckWithPrimitiveProperties.java | 43 ---- .../api/checks/CheckWithStringProperty.java | 36 ---- .../CheckWithUnsupportedPropertyType.java | 32 --- .../api/checks/CheckWithoutProperties.java | 29 --- .../sonar/api/checks/ImplementedCheck.java | 28 --- 13 files changed, 766 deletions(-) delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/checks/CheckFactory.java delete mode 100644 sonar-plugin-api/src/main/java/org/sonar/api/checks/package-info.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java delete mode 100644 sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java deleted file mode 100644 index 397965bac4b..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/AnnotationCheckFactory.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import com.google.common.collect.Maps; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.rule.Checks; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.ActiveRuleParam; -import org.sonar.api.utils.AnnotationUtils; -import org.sonar.api.utils.FieldUtils2; -import org.sonar.api.utils.SonarException; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -/** - * @since 2.3 - * @deprecated since 4.2 use {@link Checks} - */ -@Deprecated -public final class AnnotationCheckFactory extends CheckFactory { - - private static final String CAN_NOT_INSTANTIATE_THE_CHECK_RELATED_TO_THE_RULE = "Can not instantiate the check related to the rule "; - private Map checksByKey = Maps.newHashMap(); - - private AnnotationCheckFactory(RulesProfile profile, String repositoryKey, Collection checks) { - super(profile, repositoryKey); - groupByKey(checks); - } - - public static AnnotationCheckFactory create(RulesProfile profile, String repositoryKey, Collection checkClasses) { - AnnotationCheckFactory factory = new AnnotationCheckFactory(profile, repositoryKey, checkClasses); - factory.init(); - return factory; - } - - private void groupByKey(Collection checks) { - for (Object check : checks) { - String key = getRuleKey(check); - if (key != null) { - checksByKey.put(key, check); - } - } - } - - @Override - public Object createCheck(ActiveRule activeRule) { - Object object = checksByKey.get(activeRule.getConfigKey()); - if (object != null) { - return instantiate(activeRule, object); - } - return null; - } - - private static Object instantiate(ActiveRule activeRule, Object checkClassOrInstance) { - try { - Object check = checkClassOrInstance; - if (check instanceof Class) { - check = ((Class) checkClassOrInstance).newInstance(); - } - configureFields(activeRule, check); - return check; - - } catch (InstantiationException | IllegalAccessException e) { - throw new SonarException(CAN_NOT_INSTANTIATE_THE_CHECK_RELATED_TO_THE_RULE + activeRule, e); - - } - } - - private static void configureFields(ActiveRule activeRule, Object check) { - for (ActiveRuleParam param : activeRule.getActiveRuleParams()) { - Field field = getField(check, param.getKey()); - if (field == null) { - throw new SonarException("The field " + param.getKey() + " does not exist or is not annotated with @RuleProperty in the class " + check.getClass().getName()); - } - if (StringUtils.isNotBlank(param.getValue())) { - configureField(check, field, param.getValue()); - } - } - - } - - private static void configureField(Object check, Field field, String value) { - try { - field.setAccessible(true); - - if (field.getType().equals(String.class)) { - field.set(check, value); - - } else if (int.class == field.getType()) { - field.setInt(check, Integer.parseInt(value)); - - } else if (short.class == field.getType()) { - field.setShort(check, Short.parseShort(value)); - - } else if (long.class == field.getType()) { - field.setLong(check, Long.parseLong(value)); - - } else if (double.class == field.getType()) { - field.setDouble(check, Double.parseDouble(value)); - - } else if (boolean.class == field.getType()) { - field.setBoolean(check, Boolean.parseBoolean(value)); - - } else if (byte.class == field.getType()) { - field.setByte(check, Byte.parseByte(value)); - - } else if (Integer.class == field.getType()) { - field.set(check, Integer.parseInt(value)); - - } else if (Long.class == field.getType()) { - field.set(check, Long.parseLong(value)); - - } else if (Double.class == field.getType()) { - field.set(check, Double.parseDouble(value)); - - } else if (Boolean.class == field.getType()) { - field.set(check, Boolean.parseBoolean(value)); - - } else { - throw new SonarException("The type of the field " + field + " is not supported: " + field.getType()); - } - } catch (IllegalAccessException e) { - throw new SonarException("Can not set the value of the field " + field + " in the class: " + check.getClass().getName(), e); - } - } - - private static Field getField(Object check, String key) { - List fields = FieldUtils2.getFields(check.getClass(), true); - for (Field field : fields) { - RuleProperty propertyAnnotation = field.getAnnotation(RuleProperty.class); - if (propertyAnnotation != null && (StringUtils.equals(key, field.getName()) || StringUtils.equals(key, propertyAnnotation.key()))) { - return field; - } - } - return null; - } - - private static String getRuleKey(Object annotatedClassOrObject) { - String key = null; - Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClassOrObject, Rule.class); - if (ruleAnnotation != null) { - key = ruleAnnotation.key(); - } - Class clazz = annotatedClassOrObject.getClass(); - if (annotatedClassOrObject instanceof Class) { - clazz = (Class) annotatedClassOrObject; - } - return StringUtils.defaultIfEmpty(key, clazz.getCanonicalName()); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/CheckFactory.java b/sonar-plugin-api/src/main/java/org/sonar/api/checks/CheckFactory.java deleted file mode 100644 index 2a64233f500..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/CheckFactory.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import com.google.common.collect.Maps; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; - -import java.util.Collection; -import java.util.Map; - -/** - * @since 2.3 - * @deprecated since 4.2 use {@link org.sonar.api.batch.rule.CheckFactory} - */ -@Deprecated -public abstract class CheckFactory { - - private Map checkByActiveRule = Maps.newIdentityHashMap(); - private Map activeRuleByCheck = Maps.newIdentityHashMap(); - private RulesProfile profile; - private String repositoryKey; - - protected CheckFactory(RulesProfile profile, String repositoryKey) { - this.repositoryKey = repositoryKey; - this.profile = profile; - } - - protected void init() { - checkByActiveRule.clear(); - activeRuleByCheck.clear(); - for (ActiveRule activeRule : profile.getActiveRulesByRepository(repositoryKey)) { - C check = createCheck(activeRule); - checkByActiveRule.put(activeRule, check); - activeRuleByCheck.put(check, activeRule); - } - } - - abstract C createCheck(ActiveRule activeRule); - - public final String getRepositoryKey() { - return repositoryKey; - } - - public final Collection getChecks() { - return checkByActiveRule.values(); - } - - public final C getCheck(ActiveRule activeRule) { - return checkByActiveRule.get(activeRule); - } - - public final ActiveRule getActiveRule(C check) { - return activeRuleByCheck.get(check); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/checks/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/checks/package-info.java deleted file mode 100644 index fbaecb8710a..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/checks/package-info.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.api.checks; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java deleted file mode 100644 index 03fee5e4750..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AbstractCheck.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.RuleProperty; - -abstract class AbstractCheck { - - @RuleProperty - private Integer max; - - public Integer getMax() { - return max; - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java deleted file mode 100644 index 3b5f5d64264..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.Rule; -import org.sonar.api.utils.SonarException; - -import java.util.Arrays; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; - -public class AnnotationCheckFactoryTest { - - @org.junit.Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void createCheckWithoutProperties() { - RulesProfile profile = RulesProfile.create("repo", "java"); - ActiveRule activeRule = profile.activateRule(Rule.create("repo", "org.sonar.api.checks.CheckWithoutProperties", ""), null); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithoutProperties.class)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertThat(check).isInstanceOf(CheckWithoutProperties.class); - } - - @Test - public void createCheckWithStringProperty() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", ""); - rule.createParameter("pattern"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("pattern", "foo"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithStringProperty.class)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertThat(check).isInstanceOf(CheckWithStringProperty.class); - assertThat(((CheckWithStringProperty) check).getPattern()).isEqualTo("foo"); - } - - @Test - public void failIfMissingProperty() { - thrown.expect(SonarException.class); - - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", ""); - rule.createParameter("unknown"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("unknown", "bar"); - AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithStringProperty.class)); - } - - @Test - public void createCheckWithPrimitiveProperties() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithPrimitiveProperties", ""); - rule.createParameter("max"); - rule.createParameter("ignore"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - activeRule.setParameter("ignore", "true"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithPrimitiveProperties.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((CheckWithPrimitiveProperties) check).getMax()).isEqualTo(300); - assertThat(((CheckWithPrimitiveProperties) check).isIgnore()).isTrue(); - } - - @Test - public void createCheckWithIntegerProperty() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithIntegerProperty", ""); - rule.createParameter("max"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithIntegerProperty.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((CheckWithIntegerProperty) check).getMax()).isEqualTo(300); - } - - /** - * SONAR-3164 - */ - @Test - public void setValueOfInheritedField() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.ImplementedCheck", ""); - rule.createParameter("max"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(ImplementedCheck.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((ImplementedCheck) check).getMax()).isEqualTo(300); - } - - @Test - public void failIfPropertyTypeIsNotSupported() { - thrown.expect(SonarException.class); - - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithUnsupportedPropertyType", ""); - rule.createParameter("max"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("max", "300"); - AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithUnsupportedPropertyType.class)); - } - - @Test - public void shouldOverridePropertyKey() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithOverriddenPropertyKey", ""); - rule.createParameter("maximum"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("maximum", "300"); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithOverriddenPropertyKey.class)); - - Object check = factory.getCheck(activeRule); - assertThat(((CheckWithOverriddenPropertyKey) check).getMax()).isEqualTo(300); - } - - @Test - public void shouldWorkWithClonedRules() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "CheckWithKey", ""); - Rule clonedRule = Rule.create("repo", "CheckWithKey_2", "").setConfigKey("CheckWithKey").setTemplate(rule); - - profile.activateRule(rule, null); - profile.activateRule(clonedRule, null); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(CheckWithKey.class)); - - assertThat(factory.getChecks()).doesNotContain(new Object[] {null}); - } - - /** - * SONAR-2900 - */ - @Test - public void create_accept_objects() { - RulesProfile profile = RulesProfile.create("repo", "java"); - ActiveRule activeRule = profile.activateRule(Rule.create("repo", "org.sonar.api.checks.CheckWithoutProperties", ""), null); - CheckWithoutProperties checkInstance = new CheckWithoutProperties(); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(checkInstance)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertSame(check, checkInstance); - } - - @Test - public void create_instance_with_string_property() { - RulesProfile profile = RulesProfile.create("repo", "java"); - Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", ""); - rule.createParameter("pattern"); - - ActiveRule activeRule = profile.activateRule(rule, null); - activeRule.setParameter("pattern", "foo"); - CheckWithStringProperty checkInstance = new CheckWithStringProperty(); - AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(checkInstance)); - - Object check = factory.getCheck(activeRule); - assertNotNull(check); - assertSame(check, checkInstance); - assertThat(checkInstance.getPattern()).isEqualTo("foo"); - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java deleted file mode 100644 index bc25876836d..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithIntegerProperty.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithIntegerProperty { - - @RuleProperty - private Integer max; - - public Integer getMax() { - return max; - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java deleted file mode 100644 index 1303651733b..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithKey.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; - -@Rule(key = "CheckWithKey", priority = Priority.CRITICAL) -public class CheckWithKey { - -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java deleted file mode 100644 index 8e28510aa70..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithOverriddenPropertyKey.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithOverriddenPropertyKey{ - - @RuleProperty(key = "maximum") - private int max = 50; - - public int getMax() { - return max; - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java deleted file mode 100644 index dcc54e68a4a..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithPrimitiveProperties.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithPrimitiveProperties { - - @RuleProperty(description = "Maximum threshold") - private int max = 50; - - @RuleProperty - private boolean ignore; - - public int getMax() { - return max; - } - - public boolean isIgnore() { - return ignore; - } -} - diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java deleted file mode 100644 index 97d71bf0ce9..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithStringProperty.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithStringProperty { - - @RuleProperty - private String pattern; - - public String getPattern() { - return pattern; - } -} - diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java deleted file mode 100644 index 49dd3c01654..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithUnsupportedPropertyType.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; - -@Rule(priority = Priority.CRITICAL) -class CheckWithUnsupportedPropertyType { - - @RuleProperty - private StringBuilder max = null; - -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java deleted file mode 100644 index 0e375c6f65b..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/CheckWithoutProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; - -@Rule(priority = Priority.CRITICAL) -class CheckWithoutProperties { - -} - diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java deleted file mode 100644 index b4a956e5e4d..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/ImplementedCheck.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2016 SonarSource SA - * mailto:contact 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.checks; - -import org.sonar.check.Priority; -import org.sonar.check.Rule; - -@Rule(priority = Priority.CRITICAL) -class ImplementedCheck extends AbstractCheck { - -} -- 2.39.5