aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-08 10:00:19 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-10-08 10:00:19 +0200
commitc204a7295375a26ba83c33ccde0ba3121a3d388e (patch)
tree3bf9d23ab76a18aa949adec7a4728dbd16c5209d
parentd3a51c25cb09f85ce0bfe636787931229c0d3bb9 (diff)
parent211c40ec4a16dcd07b033aab9063d93d8b6c090f (diff)
downloadsonarqube-c204a7295375a26ba83c33ccde0ba3121a3d388e.tar.gz
sonarqube-c204a7295375a26ba83c33ccde0ba3121a3d388e.zip
Merge from branch 4.5
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb9
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java4
-rw-r--r--server/sonar-web/src/main/coffee/component-viewer/header.coffee6
-rw-r--r--server/sonar-web/src/main/coffee/component-viewer/header/issues-header.coffee9
-rw-r--r--server/sonar-web/src/main/coffee/component-viewer/main.coffee6
-rw-r--r--server/sonar-web/src/main/coffee/component-viewer/mixins/main-issues.coffee3
-rw-r--r--server/sonar-web/src/main/coffee/component-viewer/mixins/main-scm.coffee2
-rw-r--r--server/sonar-web/src/main/hbs/component-viewer/header/_cw-header-link.hbs4
-rw-r--r--server/sonar-web/src/main/hbs/component-viewer/header/cw-issues-header.hbs14
-rw-r--r--server/sonar-web/src/main/hbs/component-viewer/header/cw-scm-header.hbs2
-rw-r--r--server/sonar-web/src/main/hbs/component-viewer/header/cw-tests-header.hbs2
-rw-r--r--server/sonar-web/src/main/less/component-viewer.less2
-rw-r--r--server/sonar-web/src/main/less/icons.less5
-rw-r--r--server/sonar-web/src/main/less/style.less7
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb13
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb8
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb7
-rw-r--r--sonar-core/src/main/resources/org/sonar/l10n/core.properties1
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java10
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/package-info.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoader.java1
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java1
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java6
27 files changed, 99 insertions, 40 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb
index 771dc43a823..1d843dd911b 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/measures/measure_filter_treemap.html.erb
@@ -4,6 +4,11 @@
filterId = widget_properties['filter'].to_i
maxItems = widget_properties['maxItems'].to_i
+ # SONAR-2456
+ # When metrics are removed, we have to manually set them to the default ones
+ colorMetric = widget_properties['colorMetric'] || Metric.by_key('coverage')
+ sizeMetric = widget_properties['sizeMetric'] || Metric.by_key('ncloc')
+
filter = MeasureFilter.find_by_id(filterId.to_i)
if filter
@widget_title = link_to h(filter.name), {:controller => 'measures', :action => 'filter', :id => filter.id, :display => 'list'}
@@ -23,8 +28,8 @@
<script>
(function () {
var metrics = [
- '<%= widget_properties['colorMetric'].name -%>',
- '<%= widget_properties['sizeMetric'].name -%>'
+ '<%= colorMetric.name -%>',
+ '<%= sizeMetric.name -%>'
],
query = [
'filter=<%= filterId -%>',
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb
index 76c152ec75a..4a5f9612a88 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/treemap.html.erb
@@ -33,7 +33,8 @@
metrics: {
<%= colorMetric.name -%>: {
name: '<%= colorMetric.short_name -%>',
- direction: <%= colorMetric.direction -%>
+ direction: <%= colorMetric.direction -%>,
+ type: '<%= colorMetric.val_type -%>'
},
<%= sizeMetric.name -%>: {
name: '<%= sizeMetric.short_name -%>'
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java
index 6a88278800e..9868a85f8f6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java
@@ -106,6 +106,10 @@ public class RuleIndexMediumTest extends SearchMediumTest {
Result result = index.search(query, new QueryContext().setFacet(false));
assertThat(result.getFacets()).isEmpty();
+ // should not have any facet on non matching query!
+ result = index.search(new RuleQuery().setQueryText("aeiou"), new QueryOptions().setFacet(true));
+ assertThat(result.getFacets()).isEmpty();
+
// Repositories Facet is preset
result = index.search(query, new QueryContext().setFacet(true));
assertThat(result.getFacets()).isNotNull();
diff --git a/server/sonar-web/src/main/coffee/component-viewer/header.coffee b/server/sonar-web/src/main/coffee/component-viewer/header.coffee
index 175a4c59221..c39e9f1a7e8 100644
--- a/server/sonar-web/src/main/coffee/component-viewer/header.coffee
+++ b/server/sonar-web/src/main/coffee/component-viewer/header.coffee
@@ -173,7 +173,11 @@ define [
unless active
el.addClass 'active'
scope = el.data 'scope'
- @enableBar scope
+ @enableBar(scope).done =>
+ @$('.js-filter-unresolved-issues').click() if scope == 'issues'
+ @$('.js-filter-lines-to-cover').click() if scope == 'coverage'
+ @$('.js-filter-duplications').click() if scope == 'duplications'
+ @$('.js-filter-modified-lines').click() if scope == 'scm'
changeSettings: ->
diff --git a/server/sonar-web/src/main/coffee/component-viewer/header/issues-header.coffee b/server/sonar-web/src/main/coffee/component-viewer/header/issues-header.coffee
index b765c2f3cc4..9da852a2ffa 100644
--- a/server/sonar-web/src/main/coffee/component-viewer/header/issues-header.coffee
+++ b/server/sonar-web/src/main/coffee/component-viewer/header/issues-header.coffee
@@ -103,6 +103,7 @@ define [
rule = $(e.currentTarget).data 'rule'
@header.filterLines e, 'filterByRule', rule
@state.set 'activeHeaderItem', ".js-filter-rule[data-rule='#{rule}']"
+ setTimeout (=> @scrollToRule rule), 0
filterByBlockerIssues: (e) ->
@@ -135,6 +136,14 @@ define [
@state.set 'activeHeaderItem', '.js-filter-INFO-issues'
+ scrollToRule: (rule) ->
+ ruleEl = @$('.js-filter-rule').filter("[data-rule=\"#{rule}\"]")
+ container = ruleEl.closest '.component-viewer-header-expanded-bar-section-list'
+ topOffset = ruleEl.offset().top - container.offset().top
+ if topOffset > container.height()
+ container.scrollTop topOffset
+
+
serializeData: ->
_.extend super,
period: @state.get('period')?.toJSON()
diff --git a/server/sonar-web/src/main/coffee/component-viewer/main.coffee b/server/sonar-web/src/main/coffee/component-viewer/main.coffee
index 9f65306e531..15e2a13d138 100644
--- a/server/sonar-web/src/main/coffee/component-viewer/main.coffee
+++ b/server/sonar-web/src/main/coffee/component-viewer/main.coffee
@@ -185,9 +185,9 @@ define [
# Periods
@periods.reset [{label: t('none')}]
data.periods.forEach (p) =>
- d = new Date p[2]
- d.setHours 0, 0, 0, 0
- p = @periods.add key: p[0], label: p[1], sinceDate: d
+ d = moment p[2]
+ date = new Date d.get('year'), d.get('month'), d.get('date')
+ p = @periods.add key: p[0], label: p[1], sinceDate: date
requestMeasures: (key, period = null) ->
diff --git a/server/sonar-web/src/main/coffee/component-viewer/mixins/main-issues.coffee b/server/sonar-web/src/main/coffee/component-viewer/mixins/main-issues.coffee
index 477420b5d29..5c3d522595a 100644
--- a/server/sonar-web/src/main/coffee/component-viewer/mixins/main-issues.coffee
+++ b/server/sonar-web/src/main/coffee/component-viewer/mixins/main-issues.coffee
@@ -84,7 +84,8 @@ define [
if period
p = predicate
predicate = (issue) =>
- (new Date(issue.creationDate) >= period.get('sinceDate')) && p issue
+ creationDate = new Date moment(issue.creationDate).format()
+ (creationDate >= period.get('sinceDate')) && p issue
if requestIssues && !@state.get 'hasIssues'
@requestIssues(@key).done => @_filterByIssues(predicate)
diff --git a/server/sonar-web/src/main/coffee/component-viewer/mixins/main-scm.coffee b/server/sonar-web/src/main/coffee/component-viewer/mixins/main-scm.coffee
index d13be6b4e18..3691672b0b9 100644
--- a/server/sonar-web/src/main/coffee/component-viewer/mixins/main-scm.coffee
+++ b/server/sonar-web/src/main/coffee/component-viewer/mixins/main-scm.coffee
@@ -62,11 +62,11 @@ define [], () ->
_filterBySCM: () ->
formattedSource = @source.get 'formattedSource'
period = @state.get 'period'
+ @settings.set 'scm', true
unless period?
return @showAllLines()
else
periodDate = period.get 'sinceDate'
- @settings.set 'scm', true
@sourceView.resetShowBlocks()
scmBlockLine = 1
predicate = false
diff --git a/server/sonar-web/src/main/hbs/component-viewer/header/_cw-header-link.hbs b/server/sonar-web/src/main/hbs/component-viewer/header/_cw-header-link.hbs
index 70f66492319..f61e72781c6 100644
--- a/server/sonar-web/src/main/hbs/component-viewer/header/_cw-header-link.hbs
+++ b/server/sonar-web/src/main/hbs/component-viewer/header/_cw-header-link.hbs
@@ -1,5 +1,5 @@
<li><a class="item {{cl}}" data-metric="{{label}}">
<span class="label">{{t 'metric' label 'name'}}</span>
<span class="number">{{value}}</span>
- <i class="icon-chevron-right"></i>
-</a></li> \ No newline at end of file
+ <i class="icon-component-viewer-filter"></i>
+</a></li>
diff --git a/server/sonar-web/src/main/hbs/component-viewer/header/cw-issues-header.hbs b/server/sonar-web/src/main/hbs/component-viewer/header/cw-issues-header.hbs
index 91ba1ecc927..4f8fcbfbcd9 100644
--- a/server/sonar-web/src/main/hbs/component-viewer/header/cw-issues-header.hbs
+++ b/server/sonar-web/src/main/hbs/component-viewer/header/cw-issues-header.hbs
@@ -14,31 +14,31 @@
{{#if currentIssue}}
<li><a class="item js-filter-current-issue">
<span>{{t 'component_viewer.issues.current_issue'}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{/if}}
{{#unless state.removed}}
<li><a class="item js-filter-unresolved-issues">
<span>{{t 'component_viewer.issues.unresolved_issues'}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{/unless}}
{{#unless state.removed}}
<li><a class="item js-filter-open-issues">
<span>{{t 'component_viewer.issues.open_issues'}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{/unless}}
{{#unless state.removed}}
<li><a class="item js-filter-fixed-issues">
<span>{{t 'component_viewer.issues.fixed_issues'}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{/unless}}
{{#unless state.removed}}
<li><a class="item js-filter-false-positive-issues">
<span>{{t 'component_viewer.issues.false_positive_issues'}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{/unless}}
</ul>
@@ -55,7 +55,7 @@
<li><a class="item js-filter-{{key}}-issues">
<span>{{severityIcon key}} {{name}}</span>
<span class="number">{{count}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{else}}
<li><span class="item">
@@ -79,7 +79,7 @@
<li><a class="item js-filter-rule" data-rule="{{key}}" title="{{name}}">
<span>{{name}}</span>
<span class="number">{{count}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{else}}
<li><span class="item">
diff --git a/server/sonar-web/src/main/hbs/component-viewer/header/cw-scm-header.hbs b/server/sonar-web/src/main/hbs/component-viewer/header/cw-scm-header.hbs
index 2cf3da9e995..d208b7cb185 100644
--- a/server/sonar-web/src/main/hbs/component-viewer/header/cw-scm-header.hbs
+++ b/server/sonar-web/src/main/hbs/component-viewer/header/cw-scm-header.hbs
@@ -8,7 +8,7 @@
<ul class="component-viewer-header-expanded-bar-section-list">
<li><a class="item js-filter-modified-lines">
<span>{{t 'component_viewer.scm.modified_lines'}}</span>
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
</ul>
</div>
diff --git a/server/sonar-web/src/main/hbs/component-viewer/header/cw-tests-header.hbs b/server/sonar-web/src/main/hbs/component-viewer/header/cw-tests-header.hbs
index c11d69bc279..6cba8cef9c4 100644
--- a/server/sonar-web/src/main/hbs/component-viewer/header/cw-tests-header.hbs
+++ b/server/sonar-web/src/main/hbs/component-viewer/header/cw-tests-header.hbs
@@ -72,7 +72,7 @@
{{#if coveredLines}}
<span class="number">{{coveredLines}}</span>
{{/if}}
- <i class="icon-chevron-right"></i>
+ <i class="icon-component-viewer-filter"></i>
</a></li>
{{else}}
<li><span class="item" data-name="{{name}}" data-status="{{status}}" title="{{name}}">
diff --git a/server/sonar-web/src/main/less/component-viewer.less b/server/sonar-web/src/main/less/component-viewer.less
index 58ee62b571d..a24fcd828ab 100644
--- a/server/sonar-web/src/main/less/component-viewer.less
+++ b/server/sonar-web/src/main/less/component-viewer.less
@@ -556,7 +556,7 @@
& > i {
position: absolute;
top: 50%;
- right: 10px;
+ right: 6px;
margin-top: -7px;
}
diff --git a/server/sonar-web/src/main/less/icons.less b/server/sonar-web/src/main/less/icons.less
index f13dc75e7d5..fa174f8b19b 100644
--- a/server/sonar-web/src/main/less/icons.less
+++ b/server/sonar-web/src/main/less/icons.less
@@ -516,6 +516,11 @@ a[class^="icon-"], a[class*=" icon-"] {
content: "\f016";
font-size: @iconFontSize;
}
+.icon-component-viewer-filter:before {
+ content: "\e60e";
+ color: #999;
+ font-size: @iconSmallFontSize;
+}
/*
diff --git a/server/sonar-web/src/main/less/style.less b/server/sonar-web/src/main/less/style.less
index 9a888925388..72388c0ba34 100644
--- a/server/sonar-web/src/main/less/style.less
+++ b/server/sonar-web/src/main/less/style.less
@@ -1744,9 +1744,12 @@ ul.bullet li {
}
.rule-desc pre, .property pre, .bubble-popup pre, .coding-rules-detail-parameter pre {
+ display: inline-block;
+ min-width: 100%;
margin: 10px 0 !important;
padding: 10px !important;
border: 1px dashed #aaa;
+ .box-sizing(border-box);
font-size: 12px;
font-family: monospace;;
}
@@ -2606,8 +2609,8 @@ div.rule-title {
cursor: pointer;
.trans;
- &:hover {
- .scale(0.95);
+ &:hover .treemap-inner {
+ text-decoration: underline;
}
}
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
index 008f76db170..b6a5ba9f4e2 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
@@ -40,11 +40,16 @@ class ProfilesController < ApplicationController
require_parameters 'key'
call_backend do
@profile = Internal.qprofile_loader.getByKey(params[:key])
- not_found('Profile not found') unless @profile
- @deprecated_active_rules = Internal.qprofile_loader.countDeprecatedActiveRulesByProfile(@profile.getKey())
- @stats = Internal.qprofile_loader.getStatsByProfile(@profile.getKey())
+ if @profile
+ @deprecated_active_rules = Internal.qprofile_loader.countDeprecatedActiveRulesByProfile(@profile.getKey())
+ @stats = Internal.qprofile_loader.getStatsByProfile(@profile.getKey())
+ set_profile_breadcrumbs
+ else
+ # SONAR-5630
+ flash[:error] = message('quality_profiles.deleted_profile', :params => params[:key])
+ redirect_to :controller => 'profiles', :action => 'index'
+ end
end
- set_profile_breadcrumbs
end
# GET /profiles/create_form?language=<language>
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb
index d29a32f37d6..1c86a0f75b5 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/system_controller.rb
@@ -25,11 +25,15 @@ class SystemController < ApplicationController
def index
@server=Server.new
-
+
+ filename = 'SystemInfo'
+ server_id = @server.sonar_property(ServerIdConfigurationController::PROPERTY_SERVER_ID)
+ filename += '-' + server_id.to_s if server_id
+
respond_to do |format|
format.html
format.csv {
- send_data(to_csv, :type => 'text/csv; charset=utf-8', :disposition => 'attachment; filename=sonar_system_info.csv')
+ send_data(to_csv, :type => 'text/csv; charset=utf-8', :disposition => "attachment; filename=#{filename}.csv")
}
end
end
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb
index 96acb93ad75..51b86ddeffb 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/models/server.rb
@@ -20,7 +20,7 @@
class Server
def info
- system_info + sonar_info + system_statistics + sonar_plugins + system_properties + search_info
+ system_info + sonar_info + system_statistics + sonar_plugins + system_properties + cluster_info + nodes_info
end
def system_info
@@ -129,6 +129,9 @@ class Server
system_properties
end
+ def sonar_property(key)
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getContainer().getComponentByType(Java::OrgApacheCommonsConfiguration::Configuration.java_class).getProperty(key)
+ end
private
@@ -156,7 +159,7 @@ class Server
end
def sonar_property(key)
- Java::OrgSonarServerUi::JRubyFacade.getInstance().getConfigurationValue(key)
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getContainer().getComponentByType(Java::OrgApacheCommonsConfiguration::Configuration.java_class).getProperty(key)
end
def realm_name
diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
index ec0dbee110e..19f2bb84151 100644
--- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties
+++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties
@@ -1649,6 +1649,7 @@ quality_profiles.changelog.activated=Activated
quality_profiles.changelog.deactivated=Deactivated
quality_profiles.changelog.updated=Updated
quality_profiles.changelog.parameter_reset_to_default_value_x=Parameter <b>{0}</b> reset to default value
+quality_profiles.deleted_profile=The profile {0} doesn't exists anymore
#------------------------------------------------------------------------------
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
index ea8d36749eb..ab8ff4fbdec 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
@@ -41,9 +41,9 @@ import java.util.Map;
* <p/>
* Example of check class:
* <pre>
- * @Rule(key = "S001")
+ * {@literal @}org.sonar.check.Rule(key = "S001")
* public class CheckS001 {
- * @RuleProperty
+ * {@literal @}org.sonar.check.RuleProperty
* private String pattern;
*
* public String getPattern() {
@@ -69,8 +69,7 @@ import java.util.Map;
*
* // Checks are used to detect issues on source code
*
- * // checks.ruleKey(obj) can be used to create the detected
- * // issues.
+ * // checks.ruleKey(obj) can be used to create the related issues
* }
* }
* </pre>
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java
index 22d915c20fc..7690bd56c94 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Rules.java
@@ -27,15 +27,25 @@ import javax.annotation.CheckForNull;
import java.util.Collection;
/**
+ * Searches for rules. This component is available by dependency injection. It must not
+ * be extended by plugins.
+ *
* @since 4.2
*/
public interface Rules extends BatchComponent {
+ /**
+ * Get a rule by its key. Returns <code>null</code> if rule does not exist.
+ */
@CheckForNull
Rule find(RuleKey key);
Collection<Rule> findAll();
+ /**
+ * Get the rules of the given repository. Returns an empty collection if the
+ * repository does not exist.
+ */
Collection<Rule> findByRepository(String repository);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java
index b9c12ac320e..74bd4939f42 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/DatabaseSession.java
@@ -26,7 +26,7 @@ import javax.persistence.Query;
import java.util.List;
/**
- * This component should not accessible from plugin API
+ * This component should not be accessed by plugins. Database is not an API.
*
* @since 1.10
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/package-info.java
index b28c437c37f..e4820ed925b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/package-info.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/package-info.java
@@ -17,6 +17,9 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+/**
+ * Replaced by {@link org.sonar.api.batch.fs}
+ */
@ParametersAreNonnullByDefault
package org.sonar.api.scan.filesystem;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
index aae2be99ea3..ac9e7c34fa3 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java
@@ -41,7 +41,7 @@ import java.util.Map;
import java.util.Set;
/**
- * Defines the coding rules. For example the Java Findbugs plugin provides an implementation of
+ * Defines some coding rules of the same repository. For example the Java Findbugs plugin provides an implementation of
* this extension point in order to define the rules that it supports.
* <p/>
* This interface replaces the deprecated class org.sonar.api.rules.RuleRepository.
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoader.java
index 5c455ebdbf6..0c2a08f3dcc 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionAnnotationLoader.java
@@ -39,6 +39,7 @@ import java.util.List;
* Read definitions of rules based on the annotations provided by sonar-check-api. It is used
* to feed {@link RulesDefinition}.
*
+ * @see org.sonar.api.server.rule.RulesDefinition
* @since 4.3
*/
public class RulesDefinitionAnnotationLoader {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
index 240420d1ee2..72e2b545f06 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinitionXmlLoader.java
@@ -77,6 +77,7 @@ import java.util.List;
* &lt;/rules&gt;
* </pre>
*
+ * @see org.sonar.api.server.rule.RulesDefinition
* @since 4.3
*/
public class RulesDefinitionXmlLoader implements ServerComponent {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
index dae32cfc019..f4e5cb7a889 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
@@ -218,9 +218,9 @@ public final class KeyValueFormat {
if (data != null) {
String[] pairs = StringUtils.split(data, PAIR_SEPARATOR);
for (String pair : pairs) {
- String[] keyValue = StringUtils.split(pair, FIELD_SEPARATOR);
- String key = keyValue[0];
- String value = keyValue.length == 2 ? keyValue[1] : "";
+ int indexOfEqualSign = pair.indexOf(FIELD_SEPARATOR);
+ String key = pair.substring(0, indexOfEqualSign);
+ String value = pair.substring(indexOfEqualSign + 1);
map.put(keyConverter.parse(key), valueConverter.parse(value));
}
}