-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRubyPlugin.java
More file actions
115 lines (100 loc) · 4.52 KB
/
RubyPlugin.java
File metadata and controls
115 lines (100 loc) · 4.52 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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* SonarSource Ruby
* Copyright (C) 2018-2026 SonarSource Sàrl
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
*
* 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 Sonar Source-Available License for more details.
*
* You should have received a copy of the Sonar Source-Available License
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
package org.sonarsource.ruby.plugin;
import org.sonar.api.Plugin;
import org.sonar.api.PropertyType;
import org.sonar.api.SonarProduct;
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinition.ConfigScope;
import org.sonarsource.ruby.externalreport.rubocop.RuboCopRulesDefinition;
import org.sonarsource.ruby.externalreport.rubocop.RuboCopSensor;
public class RubyPlugin implements Plugin {
public static final String RUBY_LANGUAGE_KEY = "ruby";
static final String RUBY_LANGUAGE_NAME = "Ruby";
static final String RUBY_FILE_SUFFIXES_DEFAULT_VALUE = ".rb";
static final String RUBY_FILE_SUFFIXES_KEY = "sonar.ruby.file.suffixes";
static final String REPORT_PATHS_DEFAULT_VALUE = "coverage/.resultset.json";
static final String REPORT_PATHS_KEY = "sonar.ruby.coverage.reportPaths";
static final String EXCLUSIONS_KEY = "sonar.ruby.exclusions";
static final String EXCLUSIONS_DEFAULT_VALUE = "**/vendor/**";
static final String RUBY_REPOSITORY_KEY = "ruby";
static final String REPOSITORY_NAME = "SonarAnalyzer";
static final String PROFILE_NAME = "Sonar way";
private static final String GENERAL = "General";
private static final String RUBY_CATEGORY = "Ruby";
private static final String TEST_COVERAGE_SUBCATEGORY = "Test and Coverage";
private static final String EXTERNAL_ANALYZERS_CATEGORY = "External Analyzers";
@Override
public void define(Context context) {
context.addExtensions(
RubyLanguage.class,
RubySensor.class,
RubyExclusionsFileFilter.class,
RubyProfileDefinition.class,
RubyRulesDefinition.class);
if (context.getRuntime().getProduct() != SonarProduct.SONARLINT) {
context.addExtensions(
RuboCopRulesDefinition.class,
RuboCopSensor.class,
SimpleCovSensor.class,
PropertyDefinition.builder(RubySensor.SKIP_PROPERTY_KEY)
.defaultValue("true")
.name("Internal: Skip Ruby Sensor")
.description("Internal property to disable the Ruby sensor. Set to false to re-enable Ruby analysis.")
.type(PropertyType.BOOLEAN)
.category(RUBY_CATEGORY)
.subCategory(GENERAL)
.onlyOnConfigScopes(ConfigScope.PROJECT)
.build(),
PropertyDefinition.builder(RUBY_FILE_SUFFIXES_KEY)
.defaultValue(RUBY_FILE_SUFFIXES_DEFAULT_VALUE)
.name("File Suffixes")
.description("List of suffixes for files to analyze.")
.subCategory(GENERAL)
.category(RUBY_CATEGORY)
.multiValues(true)
.onConfigScopes(ConfigScope.PROJECT)
.build(),
PropertyDefinition.builder(EXCLUSIONS_KEY)
.defaultValue(EXCLUSIONS_DEFAULT_VALUE)
.name("Ruby Exclusions")
.description("List of file path patterns to be excluded from analysis of Ruby files.")
.subCategory(GENERAL)
.category(RUBY_CATEGORY)
.multiValues(true)
.onConfigScopes(ConfigScope.PROJECT)
.build(),
PropertyDefinition.builder(REPORT_PATHS_KEY)
.defaultValue(REPORT_PATHS_DEFAULT_VALUE)
.name("Path to coverage report(s)")
.description("Path to coverage report files (.resultset.json) generated by SimpleCov. The path may be absolute or relative to the project base directory.")
.category(RUBY_CATEGORY)
.subCategory(TEST_COVERAGE_SUBCATEGORY)
.onConfigScopes(ConfigScope.PROJECT)
.multiValues(true)
.build(),
PropertyDefinition.builder(RuboCopSensor.REPORT_PROPERTY_KEY)
.name("RuboCop Report Files")
.description("Paths (absolute or relative) to json files with RuboCop issues.")
.category(EXTERNAL_ANALYZERS_CATEGORY)
.subCategory(RUBY_CATEGORY)
.onConfigScopes(ConfigScope.PROJECT)
.multiValues(true)
.build());
}
}
}