From e2136eabb58be699e3caf541efd4cfe7bb8c7e9f Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Fri, 27 May 2011 15:57:20 +0200 Subject: [PATCH] SONAR-2475 remove org.sonar.api.checks.checkers and org.sonar.api.checks.profiles --- .../org/sonar/batch/CheckProfileProvider.java | 64 ------- .../sonar/batch/bootstrap/ProjectModule.java | 1 - .../checkers/AnnotationCheckerFactory.java | 160 ----------------- .../api/checks/checkers/CheckerFactory.java | 33 ---- .../checks/checkers/MessageDispatcher.java | 111 ------------ .../checkers/UnvalidCheckerException.java | 42 ----- .../AnnotationCheckProfileFactory.java | 72 -------- .../org/sonar/api/checks/profiles/Check.java | 111 ------------ .../api/checks/profiles/CheckProfile.java | 136 -------------- .../checks/profiles/CheckProfileProvider.java | 35 ---- .../profiles/CheckProfileXmlMarshaller.java | 156 ---------------- .../AnnotationCheckerFactoryTest.java | 167 ------------------ .../CheckWithUnsupportedPropertyType.java | 33 ---- .../checkers/CheckerWithIntegerProperty.java | 36 ---- .../CheckerWithPrimitiveProperties.java | 43 ----- .../checkers/CheckerWithStringProperty.java | 36 ---- .../checkers/CheckerWithoutProperties.java | 29 --- .../AnnotationCheckProfileFactoryTest.java | 87 --------- .../api/checks/profiles/CheckProfileTest.java | 60 ------- .../CheckProfileXmlMarshallerTest.java | 95 ---------- .../sonar/api/checks/profiles/CheckTest.java | 61 ------- .../api/checks/profiles/FakeCheckOne.java | 37 ---- .../api/checks/profiles/FakeCheckTwo.java | 41 ----- .../samples/AnnotatedCheckWithBundles.java | 43 ----- .../samples/DetailedAnnotatedCheck.java | 44 ----- .../I18nCheckWithAlternativeBundle.java | 30 ---- .../I18nCheckWithoutDefaultLocale.java | 27 --- .../checks/samples/SimpleAnnotatedCheck.java | 45 ----- .../CheckProfileXmlMarshallerTest/profile.xml | 17 -- .../AnnotatedCheckWithBundles.properties | 6 - .../AnnotatedCheckWithBundles_fr.properties | 6 - ...18nCheckWithoutDefaultLocale_fr.properties | 2 - .../path/AlternativeBundle.properties | 2 - 33 files changed, 1868 deletions(-) delete mode 100644 sonar-batch/src/main/java/org/sonar/batch/CheckProfileProvider.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/AnnotationCheckerFactory.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/CheckerFactory.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/MessageDispatcher.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/UnvalidCheckerException.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactory.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/Check.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfile.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileProvider.java delete mode 100644 sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshaller.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/AnnotationCheckerFactoryTest.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckWithUnsupportedPropertyType.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithIntegerProperty.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithPrimitiveProperties.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithStringProperty.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithoutProperties.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactoryTest.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileTest.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckTest.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckOne.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckTwo.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/samples/DetailedAnnotatedCheck.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithAlternativeBundle.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale.java delete mode 100644 sonar-deprecated/src/test/java/org/sonar/api/checks/samples/SimpleAnnotatedCheck.java delete mode 100644 sonar-deprecated/src/test/resources/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest/profile.xml delete mode 100644 sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.properties delete mode 100644 sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles_fr.properties delete mode 100644 sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale_fr.properties delete mode 100644 sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/alternative/path/AlternativeBundle.properties diff --git a/sonar-batch/src/main/java/org/sonar/batch/CheckProfileProvider.java b/sonar-batch/src/main/java/org/sonar/batch/CheckProfileProvider.java deleted file mode 100644 index cfe58e7aec4..00000000000 --- a/sonar-batch/src/main/java/org/sonar/batch/CheckProfileProvider.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.batch; - -import org.picocontainer.injectors.ProviderAdapter; -import org.sonar.api.checks.profiles.Check; -import org.sonar.api.checks.profiles.CheckProfile; -import org.sonar.api.profiles.RulesProfile; -import org.sonar.api.rules.ActiveRule; -import org.sonar.api.rules.ActiveRuleParam; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class CheckProfileProvider extends ProviderAdapter { - - private CheckProfile profile = null; - - public CheckProfile provide(RulesProfile ruleProfile) { - if (profile == null) { - profile = new CheckProfile(ruleProfile.getName(), ruleProfile.getLanguage()); - for (ActiveRule activeRule : ruleProfile.getActiveRules()) { - Check check = toCheck(activeRule); - profile.addCheck(check); - } - } - return profile; - } - - private Check toCheck(ActiveRule activeRule) { - Check check = new Check(activeRule.getPluginName(), activeRule.getRuleKey()); - check.setPriority(activeRule.getSeverity().toCheckPriority()); - check.setProperties(toParameters(activeRule.getActiveRuleParams())); - return check; - } - - private Map toParameters(List params) { - Map map = new HashMap(); - if (params != null) { - for (ActiveRuleParam param : params) { - map.put(param.getRuleParam().getKey(), param.getValue()); - } - } - return map; - } -} diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java index 7f1827a9808..1ea854e61de 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/ProjectModule.java @@ -95,7 +95,6 @@ public class ProjectModule extends Module { addComponent(PastViolationsLoader.class); addComponent(ProfileLoader.class, DefaultProfileLoader.class); addAdapter(new ProfileProvider()); - addAdapter(new CheckProfileProvider()); } private void addCoreComponents() { diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/AnnotationCheckerFactory.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/AnnotationCheckerFactory.java deleted file mode 100644 index 78b36dfa0a8..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/AnnotationCheckerFactory.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.apache.commons.lang.StringUtils; -import org.sonar.api.checks.profiles.Check; -import org.sonar.api.checks.profiles.CheckProfile; -import org.sonar.check.AnnotationIntrospector; -import org.sonar.check.CheckProperty; - -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Map; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated - -public class AnnotationCheckerFactory extends CheckerFactory { - - private CheckProfile profile; - private String repositoryKey; - private Collection> checkerClasses; - - public AnnotationCheckerFactory(CheckProfile profile, String repositoryKey, Collection> checkerClasses) { - this.profile = profile; - this.repositoryKey = repositoryKey; - this.checkerClasses = checkerClasses; - } - - public Map create() { - Map> classesByKey = getClassesByKey(checkerClasses); - - Map map = new IdentityHashMap(); - for (Check check : profile.getChecks(repositoryKey)) { - Class clazz = classesByKey.get(check.getTemplateKey()); - if (clazz != null) { - CHECKER checker = instantiate(check, clazz); - if (checker != null) { - map.put(check, checker); - } - } - } - return map; - } - - CHECKER instantiate(Check check, Class clazz) { - try { - CHECKER checker = clazz.newInstance(); - configureFields(check, checker); - return checker; - - } catch (UnvalidCheckerException e) { - throw e; - - } catch (Exception e) { - throw new UnvalidCheckerException("The checker " + clazz.getCanonicalName() + " can not be created", e); - } - } - - private void configureFields(Check check, CHECKER checker) throws IllegalAccessException { - for (Map.Entry entry : check.getProperties().entrySet()) { - Field field = getField(checker, entry.getKey()); - if (field == null) { - throw new UnvalidCheckerException("The field " + entry.getKey() + " does not exist or is not annotated with @CheckProperty"); - } - if (StringUtils.isNotBlank(entry.getValue())) { - configureField(checker, field, entry); - } - } - - } - - private void configureField(Object checker, Field field, Map.Entry parameter) throws IllegalAccessException { - field.setAccessible(true); - - if (field.getType().equals(String.class)) { - field.set(checker, parameter.getValue()); - - } else if (field.getType().getSimpleName().equals("int")) { - field.setInt(checker, Integer.parseInt(parameter.getValue())); - - } else if (field.getType().getSimpleName().equals("short")) { - field.setShort(checker, Short.parseShort(parameter.getValue())); - - } else if (field.getType().getSimpleName().equals("long")) { - field.setLong(checker, Long.parseLong(parameter.getValue())); - - } else if (field.getType().getSimpleName().equals("double")) { - field.setDouble(checker, Double.parseDouble(parameter.getValue())); - - } else if (field.getType().getSimpleName().equals("boolean")) { - field.setBoolean(checker, Boolean.parseBoolean(parameter.getValue())); - - } else if (field.getType().getSimpleName().equals("byte")) { - field.setByte(checker, Byte.parseByte(parameter.getValue())); - - } else if (field.getType().equals(Integer.class)) { - field.set(checker, new Integer(Integer.parseInt(parameter.getValue()))); - - } else if (field.getType().equals(Long.class)) { - field.set(checker, new Long(Long.parseLong(parameter.getValue()))); - - } else if (field.getType().equals(Double.class)) { - field.set(checker, new Double(Double.parseDouble(parameter.getValue()))); - - } else if (field.getType().equals(Boolean.class)) { - field.set(checker, Boolean.valueOf(Boolean.parseBoolean(parameter.getValue()))); - - } else { - throw new UnvalidCheckerException("The type of the field " + field + " is not supported: " + field.getType()); - } - } - - private Field getField(Object checker, String key) { - Field[] fields = checker.getClass().getDeclaredFields(); - for (Field field : fields) { - CheckProperty annotation = field.getAnnotation(CheckProperty.class); - if (annotation != null) { - if (key.equals(field.getName()) || key.equals(annotation.key())) { - return field; - } - } - } - return null; - } - - private Map> getClassesByKey(Collection> checkerClasses) { - Map> result = new HashMap>(); - for (Class checkerClass : checkerClasses) { - String key = AnnotationIntrospector.getCheckKey(checkerClass); - if (key != null) { - result.put(key, checkerClass); - } - } - return result; - } - -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/CheckerFactory.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/CheckerFactory.java deleted file mode 100644 index 1c28fca8493..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/CheckerFactory.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.sonar.api.checks.profiles.Check; - -import java.util.Map; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public abstract class CheckerFactory { - public abstract Map create(); -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/MessageDispatcher.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/MessageDispatcher.java deleted file mode 100644 index 242693eb485..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/MessageDispatcher.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import com.google.common.collect.Maps; -import org.sonar.api.batch.SensorContext; -import org.sonar.api.checks.profiles.Check; -import org.sonar.api.checks.profiles.CheckProfile; -import org.sonar.api.resources.Resource; -import org.sonar.api.rules.Rule; -import org.sonar.api.rules.RulePriority; -import org.sonar.api.rules.Violation; -import org.sonar.check.Message; - -import java.util.Collection; -import java.util.Locale; -import java.util.Map; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public class MessageDispatcher { - - private Map checkersByCheck; - private Map checksByChecker; - private SensorContext context; - - public MessageDispatcher(SensorContext context) { - this.context = context; - checkersByCheck = Maps.newIdentityHashMap(); - checksByChecker = Maps.newIdentityHashMap(); - } - - public void registerChecker(Check check, Object checker) { - checkersByCheck.put(check, checker); - checksByChecker.put(checker, check); - } - - public void registerCheckers(CheckerFactory factory) { - Map map = factory.create(); - for (Map.Entry entry : map.entrySet()) { - registerChecker(entry.getKey(), entry.getValue()); - } - } - - public void registerCheckers(CheckProfile profile) { - for (Check check : profile.getChecks()) { - registerChecker(check, check); - } - } - - public Object getChecker(Check check) { - return checkersByCheck.get(check); - } - - public Check getCheck(Object checker) { - return checksByChecker.get(checker); - } - - public Collection getCheckers() { - return checkersByCheck.values(); - } - - public void unregisterCheck(Check check) { - Object checker = checkersByCheck.remove(check); - if (checker != null) { - checksByChecker.remove(checker); - } - } - - public void unregisterChecks(CheckProfile profile) { - for (Check check : profile.getChecks()) { - unregisterCheck(check); - } - } - - public void log(Resource resource, Message message) { - Object checker = message.getChecker(); - Check check = getCheck(checker); - Violation violation = Violation.create(new Rule(check.getRepositoryKey(), check.getTemplateKey()), resource); - violation.setLineId(message.getLine()); - violation.setMessage(message.getText(Locale.ENGLISH)); - violation.setSeverity(RulePriority.fromCheckPriority(check.getPriority())); - context.saveViolation(violation); - } - - public void clear() { - checkersByCheck.clear(); - checksByChecker.clear(); - } - -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/UnvalidCheckerException.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/UnvalidCheckerException.java deleted file mode 100644 index b89ec23ebc6..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/checkers/UnvalidCheckerException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public class UnvalidCheckerException extends RuntimeException { - public UnvalidCheckerException() { - } - - public UnvalidCheckerException(String message) { - super(message); - } - - public UnvalidCheckerException(String message, Throwable cause) { - super(message, cause); - } - - public UnvalidCheckerException(Throwable cause) { - super(cause); - } -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactory.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactory.java deleted file mode 100644 index ee849c50180..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.sonar.check.AnnotationIntrospector; -import org.sonar.check.BelongsToProfile; -import org.sonar.check.BelongsToProfiles; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public final class AnnotationCheckProfileFactory { - - private AnnotationCheckProfileFactory() { - } - - public static Collection create(String repositoryKey, String language, Collection checkClasses) { - Map profilesByTitle = new HashMap(); - - if (checkClasses != null) { - for (Class aClass : checkClasses) { - BelongsToProfiles belongsToProfiles = (BelongsToProfiles) aClass.getAnnotation(BelongsToProfiles.class); - if (belongsToProfiles != null) { - for (BelongsToProfile belongsToProfile : belongsToProfiles.value()) { - registerProfile(profilesByTitle, aClass, belongsToProfile, repositoryKey, language); - } - } - BelongsToProfile belongsToProfile = (BelongsToProfile) aClass.getAnnotation(BelongsToProfile.class); - registerProfile(profilesByTitle, aClass, belongsToProfile, repositoryKey, language); - } - } - - return profilesByTitle.values(); - } - - private static void registerProfile(Map profilesByTitle, Class aClass, BelongsToProfile belongsToProfile, String repositoryKey, String language) { - if (belongsToProfile != null) { - String title = belongsToProfile.title(); - CheckProfile profile = profilesByTitle.get(title); - if (profile == null) { - profile = new CheckProfile(title, language); - profilesByTitle.put(title, profile); - } - Check check = new Check(repositoryKey, AnnotationIntrospector.getCheckKey(aClass)); - check.setPriority(belongsToProfile.priority()); - profile.addCheck(check); - } - } -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/Check.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/Check.java deleted file mode 100644 index 45e5b5e9f08..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/Check.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.apache.commons.lang.builder.ToStringBuilder; -import org.sonar.check.Priority; - -import java.util.HashMap; -import java.util.Map; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public class Check { - - private String repositoryKey; - private String templateKey; - private Priority priority = null; - private final Map properties = new HashMap(); - - public Check() { - } - - public Check(String repositoryKey, String templateKey) { - this.repositoryKey = repositoryKey; - this.templateKey = templateKey; - } - - public String getTemplateKey() { - return templateKey; - } - - public String getRepositoryKey() { - return repositoryKey; - } - - public void setRepositoryKey(String repositoryKey) { - this.repositoryKey = repositoryKey; - } - - public void setTemplateKey(String templateKey) { - this.templateKey = templateKey; - } - - public Priority getPriority() { - return priority; - } - - public void setPriority(Priority priority) { - this.priority = priority; - } - - public Map getProperties() { - return properties; - } - - public String getProperty(String key) { - return properties.get(key); - } - - public void addProperty(String key, Object value) { - properties.put(key, value.toString()); - } - - public void addProperties(Map properties) { - this.properties.putAll(properties); - } - - public void setProperties(Map properties) { - this.properties.clear(); - this.properties.putAll(properties); - } - - @Override - public boolean equals(Object o) { - return o == this; - } - - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public String toString() { - return new ToStringBuilder(this) - .append("repository", repositoryKey) - .append("template", templateKey) - .append("priority", priority) - .toString(); - } -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfile.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfile.java deleted file mode 100644 index 58268e5167b..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfile.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.sonar.api.BatchExtension; -import org.sonar.api.ServerExtension; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public class CheckProfile implements BatchExtension, ServerExtension { - - private String name; - private String language; - private List checks = new ArrayList(); - - public CheckProfile(String name, String language) { - if (name == null) { - throw new IllegalArgumentException("Name can not be null"); - } - if (language == null) { - throw new IllegalArgumentException("Language can not be null"); - } - this.name = name; - this.language = language; - } - - public String getName() { - return name; - } - - public String getLanguage() { - return language; - } - - public List getChecks() { - return checks; - } - - public List getChecks(String repositoryKey) { - List result = new ArrayList(); - for (Check check : getChecks()) { - if (check.getRepositoryKey().equals(repositoryKey)) { - result.add(check); - } - } - return result; - } - - public List getChecks(String repositoryKey, String templateKey) { - List result = new ArrayList(); - List repoChecks = getChecks(repositoryKey); - for (Check repoCheck : repoChecks) { - if (repoCheck.getTemplateKey().equals(templateKey)) { - result.add(repoCheck); - } - } - return result; - } - - /** - * We assume there is only one check for this template - */ - public Check getCheck(String repositoryKey, String templateKey) { - List repoChecks = getChecks(repositoryKey); - for (Check repoCheck : repoChecks) { - if (repoCheck.getTemplateKey().equals(templateKey)) { - return repoCheck; - } - } - return null; - } - - public void addCheck(Check check) { - checks.add(check); - } - - public void setChecks(Collection list) { - checks.clear(); - checks.addAll(list); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - CheckProfile profile = (CheckProfile) o; - if (!language.equals(profile.language)) { - return false; - } - if (!name.equals(profile.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int result = name.hashCode(); - result = 31 * result + language.hashCode(); - return result; - } - - @Override - public String toString() { - return name; - } -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileProvider.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileProvider.java deleted file mode 100644 index 7f893ff5b7b..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.sonar.api.ServerExtension; - -import java.util.Collection; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public abstract class CheckProfileProvider implements ServerExtension { - - public abstract Collection provide(); - -} diff --git a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshaller.java b/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshaller.java deleted file mode 100644 index 3502c5ed307..00000000000 --- a/sonar-deprecated/src/main/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshaller.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.converters.Converter; -import com.thoughtworks.xstream.converters.MarshallingContext; -import com.thoughtworks.xstream.converters.UnmarshallingContext; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.io.xml.CompactWriter; -import com.thoughtworks.xstream.io.xml.XppDriver; -import org.apache.commons.io.IOUtils; -import org.sonar.check.Priority; - -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.Writer; -import java.util.Map; - -/** - * @since 2.1 (experimental) - * @deprecated since 2.3 - */ -@Deprecated -public final class CheckProfileXmlMarshaller { - - public static void toXml(CheckProfile profile, Writer writer) { - getXStream().toXML(profile, writer); - } - - public static CheckProfile fromXml(Reader xml) { - return (CheckProfile) getXStream().fromXML(xml); - } - - public static CheckProfile fromXmlInClasspath(String pathToXml) { - return fromXmlInClasspath(pathToXml, CheckProfileXmlMarshaller.class); - } - - public static CheckProfile fromXmlInClasspath(String pathToXml, Class clazz) { - Reader reader = new InputStreamReader(clazz.getResourceAsStream(pathToXml)); - try { - return fromXml(reader); - } finally { - IOUtils.closeQuietly(reader); - } - } - - private static XStream getXStream() { - XStream xstream = new XStream(new CompactDriver()); - xstream.setClassLoader(CheckProfileXmlMarshaller.class.getClassLoader()); - xstream.registerConverter(new CheckConverter()); - xstream.alias("profile", CheckProfile.class); - xstream.alias("check", Check.class); - xstream.addImplicitCollection(CheckProfile.class, "checks"); - return xstream; - } - - private static class CompactDriver extends XppDriver { - @Override - public HierarchicalStreamWriter createWriter(Writer out) { - return new XDataPrintWriter(out); - } - } - - - private static class XDataPrintWriter extends CompactWriter { - public XDataPrintWriter(Writer writer) { - super(writer, XML_1_0); - } - } - - private static class CheckConverter implements Converter { - - public boolean canConvert(Class clazz) { - return clazz.equals(Check.class); - } - - public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { - Check check = (Check) value; - writer.startNode("repository"); - writer.setValue(check.getRepositoryKey()); - writer.endNode(); - writer.startNode("template"); - writer.setValue(check.getTemplateKey()); - writer.endNode(); - writer.startNode("priority"); - writer.setValue(check.getPriority().toString()); - writer.endNode(); - for (Map.Entry entry : check.getProperties().entrySet()) { - if (entry.getValue() != null) { - writer.startNode("property"); - writer.startNode("key"); - writer.setValue(entry.getKey()); - writer.endNode(); - writer.startNode("value"); - // TODO is escaping automatically supported by xstream ? - writer.setValue(entry.getValue()); - writer.endNode(); - writer.endNode(); - } - } - } - - public Object unmarshal(HierarchicalStreamReader reader, - UnmarshallingContext context) { - Check check = new Check(); - while (reader.hasMoreChildren()) { - reader.moveDown(); - readValue(reader, check); - reader.moveUp(); - } - return check; - } - - private void readValue(HierarchicalStreamReader reader, Check check) { - if (reader.getNodeName().equals("repository")) { - check.setRepositoryKey(reader.getValue()); - - } else if (reader.getNodeName().equals("template")) { - check.setTemplateKey(reader.getValue()); - - } else if (reader.getNodeName().equals("priority")) { - check.setPriority(Priority.valueOf(reader.getValue())); - - } else if (reader.getNodeName().equals("property")) { - reader.moveDown(); - String key = reader.getValue(); - reader.moveUp(); - - reader.moveDown(); - String value = reader.getValue(); - reader.moveUp(); - check.addProperty(key, value); - } - } - - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/AnnotationCheckerFactoryTest.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/AnnotationCheckerFactoryTest.java deleted file mode 100644 index 64d858e3e57..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/AnnotationCheckerFactoryTest.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.sonar.api.checks.profiles.CheckProfile; -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class AnnotationCheckerFactoryTest { - - private AnnotationCheckerFactory factory = null; - - @Before - public void before() { - CheckProfile profile = new CheckProfile("test", "java"); - factory = new AnnotationCheckerFactory(profile, "repository", Arrays.asList( - CheckerWithoutProperties.class, - CheckerWithStringProperty.class, - CheckerWithPrimitiveProperties.class)); - - } - - @Test - public void createCheckerWithoutProperties() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckerWithoutProperties.class); - CheckerWithoutProperties checker = (CheckerWithoutProperties) factory.instantiate(check, CheckerWithoutProperties.class); - assertNotNull(checker); - } - - @Test - public void createCheckerWithStringProperty() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckerWithStringProperty.class); - - Map map = new HashMap(); - map.put("max", "foo"); - when(check.getProperties()).thenReturn(map); - - CheckerWithStringProperty checker = (CheckerWithStringProperty) factory.instantiate(check, CheckerWithStringProperty.class); - assertNotNull(checker); - assertThat(checker.getMax(), is("foo")); - } - - @Test(expected = UnvalidCheckerException.class) - public void failIfMissingProperty() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckerWithStringProperty.class); - - Map map = new HashMap(); - map.put("max", "foo"); - map.put("missing", "bar"); - when(check.getProperties()).thenReturn(map); - - factory.instantiate(check, CheckerWithStringProperty.class); - } - - @Test - public void createCheckerWithPrimitiveProperties() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckerWithPrimitiveProperties.class); - - Map map = new HashMap(); - map.put("max", "300"); - map.put("active", "true"); - when(check.getProperties()).thenReturn(map); - - CheckerWithPrimitiveProperties checker = (CheckerWithPrimitiveProperties) factory.instantiate(check, CheckerWithPrimitiveProperties.class); - assertNotNull(checker); - assertThat(checker.getMax(), is(300)); - assertThat(checker.isActive(), is(true)); - } - - @Test - public void createCheckerWithIntegerProperty() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckerWithIntegerProperty.class); - - Map map = new HashMap(); - map.put("max", "300"); - when(check.getProperties()).thenReturn(map); - - CheckerWithIntegerProperty checker = (CheckerWithIntegerProperty) factory.instantiate(check, CheckerWithIntegerProperty.class); - assertNotNull(checker); - assertThat(checker.getMax(), is(300)); - } - - @Test - public void createCheckerWithDefaultValues() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckerWithPrimitiveProperties.class); - when(check.getProperties()).thenReturn(new HashMap()); - - CheckerWithPrimitiveProperties checker = (CheckerWithPrimitiveProperties) factory.instantiate(check, CheckerWithPrimitiveProperties.class); - assertNotNull(checker); - assertThat(checker.getMax(), is(50)); - assertThat(checker.isActive(), is(false)); - } - - @Test(expected=UnvalidCheckerException.class) - public void checkWithUnsupportedPropertyType() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckWithUnsupportedPropertyType.class); - Map map = new HashMap(); - map.put("max", "300"); - when(check.getProperties()).thenReturn(map); - - factory.instantiate(check, CheckWithUnsupportedPropertyType.class); - } - - @Test - @Ignore("Key is not used as i18n is not managed on properties.") - public void createCheckerWithOverridenPropertyKey() { - org.sonar.api.checks.profiles.Check check = mockCheck(CheckWithOverridenPropertyKey.class); - Map map = new HashMap(); - map.put("maximum", "300"); - when(check.getProperties()).thenReturn(map); - - CheckWithOverridenPropertyKey checker = (CheckWithOverridenPropertyKey) factory.instantiate(check, CheckWithOverridenPropertyKey.class); - assertNotNull(checker); - assertThat(checker.getMax(), is(300)); - } - - - private org.sonar.api.checks.profiles.Check mockCheck(Class checkerClass) { - org.sonar.api.checks.profiles.Check check = mock(org.sonar.api.checks.profiles.Check.class); - when(check.getRepositoryKey()).thenReturn("repository"); - when(check.getTemplateKey()).thenReturn(checkerClass.getCanonicalName()); - return check; - } -} - -@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) -class CheckWithOverridenPropertyKey{ - - @CheckProperty(key = "maximum") - private int max = 50; - - public int getMax() { - return max; - } -} \ No newline at end of file diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckWithUnsupportedPropertyType.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckWithUnsupportedPropertyType.java deleted file mode 100644 index 2c5f3621ae9..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckWithUnsupportedPropertyType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) -class CheckWithUnsupportedPropertyType { - - @CheckProperty - private StringBuilder max = null; - -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithIntegerProperty.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithIntegerProperty.java deleted file mode 100644 index fc178a97333..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithIntegerProperty.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) -class CheckerWithIntegerProperty { - - @CheckProperty - private Integer max; - - public Integer getMax() { - return max; - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithPrimitiveProperties.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithPrimitiveProperties.java deleted file mode 100644 index a1532925339..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithPrimitiveProperties.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) -class CheckerWithPrimitiveProperties { - - @CheckProperty(description = "Maximum threshold") - private int max = 50; - - @CheckProperty - private boolean active; - - public int getMax() { - return max; - } - - public boolean isActive() { - return active; - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithStringProperty.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithStringProperty.java deleted file mode 100644 index bed430862f6..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithStringProperty.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) -class CheckerWithStringProperty { - - @CheckProperty(key = "maiximum") - private String max; - - public String getMax() { - return max; - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithoutProperties.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithoutProperties.java deleted file mode 100644 index a670c06be9d..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/checkers/CheckerWithoutProperties.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.checkers; - -import org.sonar.check.Check; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) -class CheckerWithoutProperties { - -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactoryTest.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactoryTest.java deleted file mode 100644 index a41a970edd5..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/AnnotationCheckProfileFactoryTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; -import org.junit.Test; -import org.sonar.check.Priority; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItem; - -/** - * Created by IntelliJ IDEA. - * User: simonbrandhof - * Date: Sep 14, 2010 - * Time: 11:02:28 AM - * To change this template use File | Settings | File Templates. - */ -public class AnnotationCheckProfileFactoryTest { - - @Test - public void noChecks() { - assertThat(AnnotationCheckProfileFactory.create("plugin_foo", "java", null).size(), is(0)); - assertThat(AnnotationCheckProfileFactory.create("plugin_foo", "java", Collections.emptyList()).size(), is(0)); - } - - @Test - public void create() { - Collection profiles = AnnotationCheckProfileFactory.create("plugin_foo", "java", Arrays.asList(FakeCheckOne.class)); - assertThat(profiles.size(), is(1)); - - CheckProfile profile = profiles.iterator().next(); - assertThat(profile.getName(), is("profile one")); - assertThat(profile.getChecks().size(), is(1)); - assertThat(profile.getChecks().get(0).getPriority(), is(Priority.MINOR)); - } - - @Test - public void provideManyProfiles() { - Collection profiles = AnnotationCheckProfileFactory.create("plugin_foo", "java", Arrays.asList(FakeCheckOne.class, FakeCheckTwo.class)); - assertThat(profiles.size(), is(2)); - - assertThat(profiles, hasItem(new CheckProfileMatcher("profile one", 2))); - assertThat(profiles, hasItem(new CheckProfileMatcher("profile two", 1))); - } -} - -class CheckProfileMatcher extends BaseMatcher { - private String name; - private int numberOfChecks; - - CheckProfileMatcher(String name, int numberOfChecks) { - this.name = name; - this.numberOfChecks = numberOfChecks; - } - - public boolean matches(Object o) { - CheckProfile profile = (CheckProfile) o; - return profile.getName().equals(name) && profile.getChecks().size() == numberOfChecks; - } - - public void describeTo(Description description) { - } -} \ No newline at end of file diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileTest.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileTest.java deleted file mode 100644 index 09ae338d880..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.junit.Test; - -import static junit.framework.Assert.*; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -public class CheckProfileTest { - - @Test - public void testCheck() { - CheckProfile profile = new CheckProfile("fake", "java"); - assertThat(profile.getName(), is("fake")); - assertThat(profile.getLanguage(), is("java")); - assertThat(profile.getChecks().size(), is(0)); - } - - @Test - public void equalsByNameAndLanguage() { - CheckProfile profile1 = new CheckProfile("fake1", "java"); - CheckProfile profile1Clone = new CheckProfile("fake1", "java"); - CheckProfile profile2 = new CheckProfile("fake1", "php"); - - assertTrue(profile1.equals(profile1)); - assertTrue(profile1.equals(profile1Clone)); - assertFalse(profile1.equals(profile2)); - - assertEquals(profile1.hashCode(), profile1Clone.hashCode()); - } - - @Test - public void addChecks() { - CheckProfile profile = new CheckProfile("fake", "java"); - profile.addCheck(new Check("repo", "template")); - - assertThat(profile.getChecks().size(), is(1)); - assertThat(profile.getChecks("repo").size(), is(1)); - assertThat(profile.getChecks("other repo").size(), is(0)); - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest.java deleted file mode 100644 index 2c33c609db6..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.apache.commons.io.IOUtils; -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.XMLUnit; -import org.junit.Before; -import org.junit.Test; -import org.sonar.check.Priority; -import org.xml.sax.SAXException; - -import java.io.IOException; -import java.io.InputStream; -import java.io.StringReader; -import java.io.StringWriter; - -import static junit.framework.Assert.assertTrue; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -public class CheckProfileXmlMarshallerTest { - - private String expectedXml; - - @Before - public void loadExpectedXml() throws IOException { - InputStream input = getClass().getResourceAsStream("/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest/profile.xml"); - try { - expectedXml = IOUtils.toString(input); - } finally { - IOUtils.closeQuietly(input); - } - } - - - @Test - public void toXml() throws IOException, SAXException { - CheckProfile profile = new CheckProfile("one", "java"); - Check check1 = new Check("checkstyle", "C1"); - check1.setPriority(Priority.MINOR); - check1.addProperty("min", "1"); - check1.addProperty("max", "3"); - profile.addCheck(check1); - - StringWriter writer = new StringWriter(); - CheckProfileXmlMarshaller.toXml(profile, writer); - - XMLUnit.setIgnoreWhitespace(true); - Diff diff = XMLUnit.compareXML(expectedXml, writer.toString()); - assertTrue(diff.similar()); - } - - - @Test - public void fromXml() throws IOException, SAXException { - CheckProfile profile = CheckProfileXmlMarshaller.fromXml(new StringReader(expectedXml)); - assertThat(profile.getName(), is("one")); - assertThat(profile.getLanguage(), is("java")); - assertThat(profile.getChecks("checkstyle").size(), is(1)); - assertThat(profile.getChecks("unknown").size(), is(0)); - - Check check = profile.getChecks("checkstyle").get(0); - assertThat(check.getRepositoryKey(), is("checkstyle")); - assertThat(check.getTemplateKey(), is("C1")); - assertThat(check.getPriority(), is(Priority.MINOR)); - - assertThat(check.getProperties().size(), is(2)); - assertThat(check.getProperty("min"), is("1")); - assertThat(check.getProperty("max"), is("3")); - } - - @Test - public void fromXmlInClasspath() { - CheckProfile profile = CheckProfileXmlMarshaller.fromXmlInClasspath("/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest/profile.xml"); - assertThat(profile.getName(), is("one")); - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckTest.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckTest.java deleted file mode 100644 index cd7f527310b..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/CheckTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static junit.framework.Assert.assertFalse; -import static junit.framework.Assert.assertTrue; -import static org.junit.Assert.assertThat; -import static org.hamcrest.core.Is.is; - -public class CheckTest { - - @Test - public void testParameters() { - Check check = new Check("fake_plugin", "fake_key"); - assertThat(check.getProperties().size(), is(0)); - - check.addProperty("foo", "bar"); - assertThat(check.getProperties().size(), is(1)); - assertThat(check.getProperties().get("foo"), is("bar")); - - Map newParams = new HashMap(); - newParams.put("foo", "new foo"); - newParams.put("hello", "world"); - - check.setProperties(newParams); - assertThat(check.getProperties().size(), is(2)); - assertThat(check.getProperties().get("foo"), is("new foo")); - assertThat(check.getProperties().get("hello"), is("world")); - } - - @Test - public void equalsByReference() { - Check check1 = new Check("fake_plugin", "fake_key"); - Check check2 = new Check("fake_plugin", "fake_key"); - - assertTrue(check1.equals(check1)); - assertFalse(check1.equals(check2)); - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckOne.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckOne.java deleted file mode 100644 index 5a5ba20e23f..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckOne.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.sonar.check.BelongsToProfile; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -/** - * Created by IntelliJ IDEA. - * User: simonbrandhof - * Date: Sep 14, 2010 - * Time: 11:02:28 AM - * To change this template use File | Settings | File Templates. - */ -@org.sonar.check.Check(priority = Priority.BLOCKER, isoCategory = IsoCategory.Maintainability) -@BelongsToProfile(title = "profile one", priority = Priority.MINOR) -class FakeCheckOne { - -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckTwo.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckTwo.java deleted file mode 100644 index a20e9de2cd3..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/profiles/FakeCheckTwo.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.profiles; - -import org.sonar.check.BelongsToProfile; -import org.sonar.check.BelongsToProfiles; -import org.sonar.check.IsoCategory; -import org.sonar.check.Priority; - -/** - * Created by IntelliJ IDEA. - * User: simonbrandhof - * Date: Sep 14, 2010 - * Time: 11:02:28 AM - * To change this template use File | Settings | File Templates. - */ -@org.sonar.check.Check(priority = Priority.BLOCKER, isoCategory = IsoCategory.Maintainability) -@BelongsToProfiles({ - @BelongsToProfile(title = "profile two", priority = Priority.INFO), - @BelongsToProfile(title = "profile one", priority = Priority.MINOR) -}) -class FakeCheckTwo { - -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.java deleted file mode 100644 index 234567e9926..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.samples; - -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; - -@Check(isoCategory = IsoCategory.Efficiency) -public final class AnnotatedCheckWithBundles { - @CheckProperty - private String max; - - @CheckProperty - protected String min; - - private int nonConfigurableProperty; - - public String getMax() { - return max; - } - - public void setMax(String max) { - this.max = max; - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/DetailedAnnotatedCheck.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/DetailedAnnotatedCheck.java deleted file mode 100644 index 1b88b783d4a..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/DetailedAnnotatedCheck.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.samples; - -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; - -@Check(title ="Detailed Check", description = "Detailed description", isoCategory = IsoCategory.Reliability) -public class DetailedAnnotatedCheck { - - @CheckProperty(description ="Maximum value") - private String max; - - @CheckProperty(description ="Minimum value") - protected String min; - - private int nonConfigurableProperty; - - public String getMax() { - return max; - } - - public void setMax(String max) { - this.max = max; - } -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithAlternativeBundle.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithAlternativeBundle.java deleted file mode 100644 index 8bf94a7fcf0..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithAlternativeBundle.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.samples; - -import org.sonar.check.Check; -import org.sonar.check.IsoCategory; - -@Check( - key = "new_key", - bundle = "org.sonar.api.checks.samples.alternative.path.AlternativeBundle", - isoCategory = IsoCategory.Efficiency) -public class I18nCheckWithAlternativeBundle { -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale.java deleted file mode 100644 index 02535aa7663..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.samples; - -import org.sonar.check.Check; -import org.sonar.check.IsoCategory; - -@Check(title = "Title from annotation", isoCategory = IsoCategory.Efficiency) -public class I18nCheckWithoutDefaultLocale { -} diff --git a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/SimpleAnnotatedCheck.java b/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/SimpleAnnotatedCheck.java deleted file mode 100644 index 2c8069efae4..00000000000 --- a/sonar-deprecated/src/test/java/org/sonar/api/checks/samples/SimpleAnnotatedCheck.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar 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. - * - * Sonar 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 Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.api.checks.samples; - -import org.sonar.check.Check; -import org.sonar.check.CheckProperty; -import org.sonar.check.IsoCategory; - -@Check(isoCategory = IsoCategory.Efficiency) -public class SimpleAnnotatedCheck { - - @CheckProperty - private String max; - - @CheckProperty - protected String min; - - private int nonConfigurableProperty; - - public String getMax() { - return max; - } - - public void setMax(String max) { - this.max = max; - } -} - diff --git a/sonar-deprecated/src/test/resources/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest/profile.xml b/sonar-deprecated/src/test/resources/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest/profile.xml deleted file mode 100644 index bcbba0f82ba..00000000000 --- a/sonar-deprecated/src/test/resources/org/sonar/api/checks/profiles/CheckProfileXmlMarshallerTest/profile.xml +++ /dev/null @@ -1,17 +0,0 @@ - - one - java - - checkstyle - - MINOR - - min - 1 - - - max - 3 - - - \ No newline at end of file diff --git a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.properties b/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.properties deleted file mode 100644 index e1d764b21b4..00000000000 --- a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles.properties +++ /dev/null @@ -1,6 +0,0 @@ -title: I18n Check -description: Description in english -property.max.title: Maximum value -property.max.description: Description in english of the maximum value -property.min.title: Minimum value -property.min.description: Description in english of the minimum value \ No newline at end of file diff --git a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles_fr.properties b/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles_fr.properties deleted file mode 100644 index 14e2f2dbbcf..00000000000 --- a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/AnnotatedCheckWithBundles_fr.properties +++ /dev/null @@ -1,6 +0,0 @@ -title: Règle d'internationalisation -description: Description en Français -property.max.title: Valeur maximale -property.max.description: Description en Français de la valeur maximale -property.min.title: Valeur minimale -property.min.description: Description en Français de la valeur minimale diff --git a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale_fr.properties b/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale_fr.properties deleted file mode 100644 index d020f8d393b..00000000000 --- a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/I18nCheckWithoutDefaultLocale_fr.properties +++ /dev/null @@ -1,2 +0,0 @@ -title: Titre depuis le bundle -description: Seul le francais est disponible dans les bundles \ No newline at end of file diff --git a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/alternative/path/AlternativeBundle.properties b/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/alternative/path/AlternativeBundle.properties deleted file mode 100644 index ceae9d0375d..00000000000 --- a/sonar-deprecated/src/test/resources/org/sonar/api/checks/samples/alternative/path/AlternativeBundle.properties +++ /dev/null @@ -1,2 +0,0 @@ -title : Alternative Path to Bundle -description : description of Alternative Path to Bundle \ No newline at end of file -- 2.39.5