001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 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 021 package org.sonar.plugins.squid; 022 023 import java.util.Arrays; 024 import java.util.List; 025 026 import org.sonar.api.resources.Java; 027 import org.sonar.api.rules.AnnotationRuleParser; 028 import org.sonar.api.rules.Rule; 029 import org.sonar.api.rules.RuleRepository; 030 import org.sonar.java.ast.check.BreakCheck; 031 import org.sonar.java.ast.check.ContinueCheck; 032 import org.sonar.java.ast.check.UndocumentedApiCheck; 033 import org.sonar.java.bytecode.check.ArchitectureCheck; 034 import org.sonar.java.bytecode.check.CallToDeprecatedMethodCheck; 035 import org.sonar.java.bytecode.check.UnusedPrivateMethodCheck; 036 import org.sonar.java.bytecode.check.UnusedProtectedMethodCheck; 037 import org.sonar.java.squid.check.*; 038 039 public final class SquidRuleRepository extends RuleRepository { 040 private AnnotationRuleParser ruleParser; 041 042 public SquidRuleRepository(AnnotationRuleParser ruleParser) { 043 super(SquidConstants.REPOSITORY_KEY, Java.KEY); 044 setName(SquidConstants.REPOSITORY_NAME); 045 this.ruleParser = ruleParser; 046 } 047 048 @Override 049 public List<Rule> createRules() { 050 return ruleParser.parse(SquidConstants.REPOSITORY_KEY, getCheckClasses()); 051 } 052 053 public static List<Class> getCheckClasses() { 054 return Arrays.asList( 055 // Bytecode checks 056 (Class) CallToDeprecatedMethodCheck.class, UnusedPrivateMethodCheck.class, UnusedProtectedMethodCheck.class, 057 ArchitectureCheck.class, 058 // AST checks 059 UndocumentedApiCheck.class, ContinueCheck.class, BreakCheck.class, 060 // Squid checks 061 DITCheck.class, ClassComplexityCheck.class, MethodComplexityCheck.class, NoSonarCheck.class, EmptyFileCheck.class); 062 } 063 }