-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathCreedengoRulesPlugin.java
More file actions
69 lines (63 loc) · 2.92 KB
/
CreedengoRulesPlugin.java
File metadata and controls
69 lines (63 loc) · 2.92 KB
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
/*
* creedengo Android plugin - Provides rules to reduce the environmental footprint of your Android applications
* Copyright © 2020 Green Code Initiative (contact@green-code-initiative.org)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.greencodeinitiative.creedengo;
import org.greencodeinitiative.creedengo.java.JavaCreedengoProfile;
import org.greencodeinitiative.creedengo.java.JavaFileCheckRegistrar;
import org.greencodeinitiative.creedengo.java.JavaRulesDefinition;
import org.greencodeinitiative.creedengo.xml.XmlCreedengoProfile;
import org.greencodeinitiative.creedengo.xml.XmlRulesDefinition;
import org.greencodeinitiative.creedengo.xml.XmlSensor;
import org.sonar.api.Plugin;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.resources.Qualifiers;
import org.sonar.plugins.groovy.GroovySensor;
import org.sonar.plugins.groovy.codenarc.CodeNarcSensor;
import org.sonar.plugins.groovy.foundation.Groovy;
/**
* Entry point of your plugin containing your custom rules
*/
public class CreedengoRulesPlugin implements Plugin {
public static final String FILE_SUFFIXES_KEY = "creedengo.xml.file.suffixes";
@Override
public void define(Context context) {
// ===Add Java rules extension ===
// server extensions -> objects are instantiated during server startup
context.addExtension(JavaRulesDefinition.class);
// batch extensions -> objects are instantiated during code analysis
context.addExtension(JavaFileCheckRegistrar.class);
// === Add Java rules profile ===
context.addExtension(JavaCreedengoProfile.class);
// === Add XML rules extension ===
context.addExtensions(
PropertyDefinition.builder(FILE_SUFFIXES_KEY)
.name("File suffixes")
.description("Comma-separated list of suffixes for files to analyze.")
.defaultValue(".xml,.xsd,.xsl")
.multiValues(true)
.category("XML")
.onQualifiers(Qualifiers.PROJECT)
.build(),
XmlRulesDefinition.class,
XmlCreedengoProfile.class,
XmlSensor.class);
// === Add Groovy rules extension ===
context.addExtensions(Groovy.getExtensions())
.addExtensions(GroovySensor.getExtensions())
.addExtensions(CodeNarcSensor.getExtensions());
}
}