001/* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2012 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 021package org.sonar.plugins.squid; 022 023import java.util.Arrays; 024import java.util.List; 025 026import org.sonar.api.resources.Java; 027import org.sonar.api.rules.AnnotationRuleParser; 028import org.sonar.api.rules.Rule; 029import org.sonar.api.rules.RuleRepository; 030import org.sonar.java.ast.check.BreakCheck; 031import org.sonar.java.ast.check.CommentedOutCodeLineCheck; 032import org.sonar.java.ast.check.ContinueCheck; 033import org.sonar.java.ast.check.UndocumentedApiCheck; 034import org.sonar.java.bytecode.check.ArchitectureCheck; 035import org.sonar.java.bytecode.check.CallToDeprecatedMethodCheck; 036import org.sonar.java.bytecode.check.UnusedPrivateMethodCheck; 037import org.sonar.java.bytecode.check.UnusedProtectedMethodCheck; 038import org.sonar.java.squid.check.*; 039 040public final class SquidRuleRepository extends RuleRepository { 041 private AnnotationRuleParser ruleParser; 042 043 public SquidRuleRepository(AnnotationRuleParser ruleParser) { 044 super(SquidConstants.REPOSITORY_KEY, Java.KEY); 045 setName(SquidConstants.REPOSITORY_NAME); 046 this.ruleParser = ruleParser; 047 } 048 049 @Override 050 public List<Rule> createRules() { 051 return ruleParser.parse(SquidConstants.REPOSITORY_KEY, getCheckClasses()); 052 } 053 054 public static List<Class> getCheckClasses() { 055 return Arrays.asList( 056 // Bytecode checks 057 (Class) CallToDeprecatedMethodCheck.class, UnusedPrivateMethodCheck.class, UnusedProtectedMethodCheck.class, 058 ArchitectureCheck.class, 059 // AST checks 060 UndocumentedApiCheck.class, ContinueCheck.class, BreakCheck.class, 061 // Squid checks 062 DITCheck.class, ClassComplexityCheck.class, MethodComplexityCheck.class, NoSonarCheck.class, EmptyFileCheck.class, 063 CommentedOutCodeLineCheck.class); 064 } 065}