@@ -14,6 +14,11 @@ | |||
<description>Squid analyzer for Java</description> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-deprecated</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.codehaus.sonar</groupId> | |||
<artifactId>sonar-squid</artifactId> |
@@ -1,5 +1,6 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>org.codehaus.sonar</groupId> | |||
@@ -18,7 +19,11 @@ | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>sonar-plugin-api</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>xmlunit</groupId> | |||
<artifactId>xmlunit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>junit</groupId> | |||
<artifactId>junit</artifactId> | |||
@@ -39,5 +44,10 @@ | |||
<artifactId>dbunit</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>ch.qos.logback</groupId> | |||
<artifactId>logback-classic</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
</dependencies> | |||
</project> |
@@ -32,8 +32,11 @@ import java.util.IdentityHashMap; | |||
import java.util.Map; | |||
/** | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class AnnotationCheckerFactory<CHECKER> extends CheckerFactory<CHECKER> { | |||
private CheckProfile profile; |
@@ -24,8 +24,10 @@ import org.sonar.api.checks.profiles.Check; | |||
import java.util.Map; | |||
/** | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public abstract class CheckerFactory<CHECKER> { | |||
public abstract Map<Check, CHECKER> create(); | |||
} |
@@ -33,6 +33,11 @@ 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<Check, Object> checkersByCheck; |
@@ -19,6 +19,11 @@ | |||
*/ | |||
package org.sonar.api.checks.checkers; | |||
/** | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class UnvalidCheckerException extends RuntimeException { | |||
public UnvalidCheckerException() { | |||
} |
@@ -27,6 +27,11 @@ 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() { |
@@ -26,8 +26,10 @@ import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* EXPERIMENTAL - will be used in version 2.2 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class Check { | |||
private String repositoryKey; |
@@ -26,6 +26,11 @@ 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; |
@@ -24,8 +24,10 @@ import org.sonar.api.ServerExtension; | |||
import java.util.Collection; | |||
/** | |||
* EXPERIMENTAL - will be used in version 2.2 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public abstract class CheckProfileProvider implements ServerExtension { | |||
public abstract Collection<CheckProfile> provide(); |
@@ -36,8 +36,10 @@ import java.io.Writer; | |||
import java.util.Map; | |||
/** | |||
* EXPERIMENTAL - will be used in version 2.3 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public final class CheckProfileXmlMarshaller { | |||
public static void toXml(CheckProfile profile, Writer writer) { |
@@ -30,8 +30,10 @@ import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* Load templates from class annotations (see the library sonar-check-api) | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class AnnotationCheckTemplateFactory { | |||
private static final Logger LOG = LoggerFactory.getLogger(AnnotationCheckTemplateFactory.class); |
@@ -27,10 +27,10 @@ import java.util.MissingResourceException; | |||
import java.util.ResourceBundle; | |||
/** | |||
* Internationalized check template. Translations are loaded from resource bundles (properties files in the classpath) | |||
* | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class BundleCheckTemplate extends CheckTemplate { | |||
private static final Logger LOG = LoggerFactory.getLogger(BundleCheckTemplate.class); | |||
@@ -21,6 +21,11 @@ package org.sonar.api.checks.templates; | |||
import java.util.Locale; | |||
/** | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class BundleCheckTemplateProperty extends CheckTemplateProperty { | |||
private BundleCheckTemplate check; |
@@ -28,10 +28,10 @@ import java.util.List; | |||
import java.util.Locale; | |||
/** | |||
* EXPERIMENTAL - will be used in version 2.2 | |||
* | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public abstract class CheckTemplate { | |||
protected String key; |
@@ -22,9 +22,10 @@ package org.sonar.api.checks.templates; | |||
import java.util.Collection; | |||
/** | |||
* EXPERIMENTAL - will be used in version 2.2 | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public abstract class CheckTemplateFactory { | |||
public abstract Collection<CheckTemplate> create(); |
@@ -22,10 +22,10 @@ package org.sonar.api.checks.templates; | |||
import java.util.Locale; | |||
/** | |||
* EXPERIMENTAL - will be used in version 2.2 | |||
* | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public abstract class CheckTemplateProperty implements Comparable<CheckTemplateProperty> { | |||
protected String key; |
@@ -26,8 +26,10 @@ import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class CheckTemplateRepositories implements ServerExtension { | |||
private Map<String, CheckTemplateRepository> repositoriesByKey = new HashMap<String, CheckTemplateRepository>(); |
@@ -29,10 +29,10 @@ import java.io.InputStream; | |||
import java.util.*; | |||
/** | |||
* EXPERIMENTAL - will be used in version 2.3 | |||
* | |||
* @since 2.1 | |||
* @since 2.1 (experimental) | |||
* @deprecated since 2.3 | |||
*/ | |||
@Deprecated | |||
public class CheckTemplateRepository implements RulesRepository { | |||
private String key; |
@@ -1,22 +1,3 @@ | |||
/* | |||
* Sonar, open source software quality management tool. | |||
* Copyright (C) 2009 SonarSource SA | |||
* 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; | |||
@@ -129,7 +110,7 @@ public class AnnotationCheckerFactoryTest { | |||
Map map = new HashMap(); | |||
map.put("max", "300"); | |||
when(check.getProperties()).thenReturn(map); | |||
factory.instantiate(check, CheckWithUnsupportedPropertyType.class); | |||
} | |||
@@ -155,59 +136,6 @@ public class AnnotationCheckerFactoryTest { | |||
} | |||
} | |||
@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) | |||
class CheckerWithoutProperties { | |||
} | |||
@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) | |||
class CheckerWithStringProperty { | |||
@CheckProperty(key = "maiximum") | |||
private String max; | |||
public String getMax() { | |||
return max; | |||
} | |||
} | |||
@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; | |||
} | |||
} | |||
@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) | |||
class CheckerWithIntegerProperty { | |||
@CheckProperty | |||
private Integer max; | |||
public Integer getMax() { | |||
return max; | |||
} | |||
} | |||
@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) | |||
class CheckWithUnsupportedPropertyType { | |||
@CheckProperty | |||
private StringBuilder max = null; | |||
} | |||
@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) | |||
class CheckWithOverridenPropertyKey{ | |||
@@ -0,0 +1,21 @@ | |||
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; | |||
/** | |||
* Created by IntelliJ IDEA. | |||
* User: simonbrandhof | |||
* Date: Sep 14, 2010 | |||
* Time: 11:20:57 AM | |||
* To change this template use File | Settings | File Templates. | |||
*/ | |||
@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) | |||
class CheckWithUnsupportedPropertyType { | |||
@CheckProperty | |||
private StringBuilder max = null; | |||
} |
@@ -0,0 +1,17 @@ | |||
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; | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
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; | |||
/** | |||
* Created by IntelliJ IDEA. | |||
* User: simonbrandhof | |||
* Date: Sep 14, 2010 | |||
* Time: 11:20:57 AM | |||
* To change this template use File | Settings | File Templates. | |||
*/ | |||
@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; | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
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; | |||
/** | |||
* Created by IntelliJ IDEA. | |||
* User: simonbrandhof | |||
* Date: Sep 14, 2010 | |||
* Time: 11:20:57 AM | |||
* To change this template use File | Settings | File Templates. | |||
*/ | |||
@Check(isoCategory = IsoCategory.Efficiency, priority = Priority.CRITICAL) | |||
class CheckerWithStringProperty { | |||
@CheckProperty(key = "maiximum") | |||
private String max; | |||
public String getMax() { | |||
return max; | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
/* | |||
* Sonar, open source software quality management tool. | |||
* Copyright (C) 2009 SonarSource SA | |||
* 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 { | |||
} |
@@ -1,30 +1,8 @@ | |||
/* | |||
* Sonar, open source software quality management tool. | |||
* Copyright (C) 2009 SonarSource SA | |||
* 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.BelongsToProfile; | |||
import org.sonar.check.BelongsToProfiles; | |||
import org.sonar.check.IsoCategory; | |||
import org.sonar.check.Priority; | |||
import java.util.Arrays; | |||
@@ -35,6 +13,13 @@ 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 | |||
@@ -64,21 +49,6 @@ public class AnnotationCheckProfileFactoryTest { | |||
} | |||
} | |||
@org.sonar.check.Check(priority = Priority.BLOCKER, isoCategory = IsoCategory.Maintainability) | |||
@BelongsToProfile(title = "profile one", priority = Priority.MINOR) | |||
class FakeCheckOne { | |||
} | |||
@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 { | |||
} | |||
class CheckProfileMatcher extends BaseMatcher<CheckProfile> { | |||
private String name; | |||
private int numberOfChecks; |
@@ -0,0 +1,18 @@ | |||
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 { | |||
} |
@@ -0,0 +1,22 @@ | |||
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 { | |||
} |
@@ -129,6 +129,8 @@ public final class ProfilesConsole implements ServerComponent { | |||
ProfileImporter importer = getProfileImporter(importerKey); | |||
RulesProfile profile = importer.importProfile(new StringReader(profileDefinition), messages); | |||
if (!messages.hasErrors()) { | |||
profile.setName(profileName); | |||
profile.setLanguage(language); | |||
DatabaseSession session = sessionFactory.getSession(); | |||
session.saveWithoutFlush(profile); | |||
session.commit(); |