-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathFindbugsPlugin.java
95 lines (86 loc) · 3.7 KB
/
FindbugsPlugin.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* SonarQube Findbugs Plugin
* Copyright (C) 2012 SonarSource
* sonarqube@googlegroups.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package org.sonar.plugins.findbugs;
import java.util.Arrays;
import java.util.stream.Collectors;
import org.sonar.api.Plugin;
import org.sonar.api.batch.fs.FilePredicate;
import org.sonar.api.batch.fs.FilePredicates;
import org.sonar.plugins.findbugs.classpath.DefaultClasspathLocator;
import org.sonar.plugins.findbugs.language.Jsp;
import org.sonar.plugins.findbugs.language.scala.Scala;
import org.sonar.plugins.findbugs.profiles.FindbugsContribProfile;
import org.sonar.plugins.findbugs.profiles.FindbugsProfile;
import org.sonar.plugins.findbugs.profiles.FindbugsSecurityAuditProfile;
import org.sonar.plugins.findbugs.profiles.FindbugsSecurityJspProfile;
import org.sonar.plugins.findbugs.profiles.FindbugsSecurityMinimalProfile;
import org.sonar.plugins.findbugs.profiles.FindbugsSecurityScalaProfile;
import org.sonar.plugins.findbugs.resource.ByteCodeResourceLocator;
import org.sonar.plugins.findbugs.rules.FbContribRulesDefinition;
import org.sonar.plugins.findbugs.rules.FindSecurityBugsJspRulesDefinition;
import org.sonar.plugins.findbugs.rules.FindSecurityBugsRulesDefinition;
import org.sonar.plugins.findbugs.rules.FindSecurityBugsScalaRulesDefinition;
import org.sonar.plugins.findbugs.rules.FindbugsRulesDefinition;
import org.sonar.plugins.java.Java;
public class FindbugsPlugin implements Plugin {
protected static final String[] SUPPORTED_JVM_LANGUAGES = {
Java.KEY,
Jsp.KEY,
Scala.KEY,
"clojure",
"kotlin",
};
protected static final String[] SUPPORTED_JVM_LANGUAGES_EXTENSIONS = {
"java",
"jsp",
"scala",
"clj",
"kt",
};
public static FilePredicate[] getSupportedLanguagesFilePredicate(FilePredicates pred) {
return Arrays.stream(SUPPORTED_JVM_LANGUAGES)
.map(s -> pred.hasLanguage(s))
.collect(Collectors.toList())
.toArray(new FilePredicate[SUPPORTED_JVM_LANGUAGES.length]);
}
@Override
public void define(Context context) {
context.addExtensions(FindbugsConfiguration.getPropertyDefinitions(context));
context.addExtensions(Arrays.asList(
FindbugsSensor.class,
FindbugsProfileExporter.class,
FindbugsProfileImporter.class,
FindbugsConfiguration.class,
FindbugsExecutor.class,
FindbugsProfile.class,
FindbugsContribProfile.class,
FindbugsSecurityAuditProfile.class,
FindbugsSecurityMinimalProfile.class,
FindbugsSecurityJspProfile.class,
FindbugsSecurityScalaProfile.class,
FindbugsRulesDefinition.class,
FbContribRulesDefinition.class,
FindSecurityBugsRulesDefinition.class,
FindSecurityBugsJspRulesDefinition.class,
FindSecurityBugsScalaRulesDefinition.class,
DefaultClasspathLocator.class,
ByteCodeResourceLocator.class));
}
}