]> source.dussan.org Git - sonarqube.git/commitdiff
resolve SONAR-5842 When a rule is already activated on all profiles, a message should...
authorStas Vilchik <vilchiks@gmail.com>
Mon, 19 Jan 2015 09:58:36 +0000 (10:58 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 19 Jan 2015 10:09:19 +0000 (11:09 +0100)
server/sonar-web/src/main/hbs/coding-rules/rule/coding-rules-profile-activation.hbs
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/app.json [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/search.json [new file with mode: 0644]
server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/show.json [new file with mode: 0644]
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 302da1eaaf66e23f43d7c18dd80c189894fc8ab2..8c9b6a91923083f2ce156170011e9c5a742cabfe 100644 (file)
   <div class="modal-body modal-body-select2">
     <div class="modal-error"></div>
 
-    <table>
-      <tr class="property">
-        <th><h3>{{t 'coding_rules.quality_profile'}}</h3></th>
-        <td>
-          {{#if key}}
-            {{name}}
-          {{else}}
-            <select id="coding-rules-quality-profile-activation-select">
-              {{#each qualityProfiles}}
-                <option value="{{key}}">{{name}}</option>
-              {{/each}}
-            </select>
-          {{/if}}
-        </td>
-      </tr>
-      <tr class="property">
-        <th><h3>{{t 'severity'}}</h3></th>
-        <td>
-          <select id="coding-rules-quality-profile-activation-severity">
-            {{#each severities}}
-              <option value="{{this}}">{{t 'severity' this}}</option>
-            {{/each}}
-          </select>
-        </td>
-      </tr>
-      {{#if isCustomRule}}
-      <tr class="property">
-        <td colspan="2" class="note">{{t 'coding_rules.custom_rule.activation_notice'}}</td>
-      {{else}}
-      {{#each params}}
+    {{#notEmpty qualityProfiles}}
+      <table>
         <tr class="property">
-          <th><h3>{{key}}</h3></th>
+          <th><h3>{{t 'coding_rules.quality_profile'}}</h3></th>
           <td>
-            {{#eq type 'TEXT'}}
-              <textarea class="width100" rows="3" name="{{key}}" placeholder="{{defaultValue}}">{{value}}</textarea>
+            {{#if key}}
+              {{name}}
             {{else}}
-              {{#eq type 'BOOLEAN'}}
-              <select name="{{key}}" value="{{value}}">
-                <option value="{{defaultValue}}">{{t 'default'}} ({{t defaultValue}})</option>
-                <option value="true"{{#eq value 'true'}} selected="selected"{{/eq}}>{{t 'true'}}</option>
-                <option value="false"{{#eq value 'false'}} selected="selected"{{/eq}}>{{t 'false'}}</option>
+              <select id="coding-rules-quality-profile-activation-select">
+                {{#each qualityProfiles}}
+                  <option value="{{key}}">{{name}}</option>
+                {{/each}}
               </select>
-              {{else}}
-              <input type="text" name="{{key}}" value="{{value}}" placeholder="{{defaultValue}}">
-              {{/eq}}
-            {{/eq}}
-            <div class="note">{{{htmlDesc}}}</div>
-            {{#if extra}}
-              <div class="note">{{extra}}</div>
             {{/if}}
           </td>
         </tr>
-      {{/each}}
-      {{/if}}
-    </table>
+        <tr class="property">
+          <th><h3>{{t 'severity'}}</h3></th>
+          <td>
+            <select id="coding-rules-quality-profile-activation-severity">
+              {{#each severities}}
+                <option value="{{this}}">{{t 'severity' this}}</option>
+              {{/each}}
+            </select>
+          </td>
+        </tr>
+        {{#if isCustomRule}}
+        <tr class="property">
+          <td colspan="2" class="note">{{t 'coding_rules.custom_rule.activation_notice'}}</td>
+        {{else}}
+        {{#each params}}
+          <tr class="property">
+            <th><h3>{{key}}</h3></th>
+            <td>
+              {{#eq type 'TEXT'}}
+                <textarea class="width100" rows="3" name="{{key}}" placeholder="{{defaultValue}}">{{value}}</textarea>
+              {{else}}
+                {{#eq type 'BOOLEAN'}}
+                <select name="{{key}}" value="{{value}}">
+                  <option value="{{defaultValue}}">{{t 'default'}} ({{t defaultValue}})</option>
+                  <option value="true"{{#eq value 'true'}} selected="selected"{{/eq}}>{{t 'true'}}</option>
+                  <option value="false"{{#eq value 'false'}} selected="selected"{{/eq}}>{{t 'false'}}</option>
+                </select>
+                {{else}}
+                <input type="text" name="{{key}}" value="{{value}}" placeholder="{{defaultValue}}">
+                {{/eq}}
+              {{/eq}}
+              <div class="note">{{{htmlDesc}}}</div>
+              {{#if extra}}
+                <div class="note">{{extra}}</div>
+              {{/if}}
+            </td>
+          </tr>
+        {{/each}}
+        {{/if}}
+      </table>
+    {{else}}
+      <div class="message-notice">{{t 'coding_rules.active_in_all_profiles'}}</div>
+    {{/notEmpty}}
   </div>
 
   <div class="modal-foot">
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation.js
new file mode 100644 (file)
index 0000000..abaed5e
--- /dev/null
@@ -0,0 +1,44 @@
+/* global casper:false */
+
+var lib = require('../lib');
+
+lib.initMessages();
+lib.changeWorkingDirectory('coding-rules-page-no-available-profiles-for-activation');
+
+
+casper.test.begin('coding-rules-page-no-available-profiles-for-activation', 2, function (test) {
+  casper
+      .start(lib.buildUrl('coding-rules'), function () {
+        lib.setDefaultViewport();
+
+        lib.mockRequest('/api/l10n/index', '{}');
+        lib.mockRequestFromFile('/api/rules/app', 'app.json');
+        lib.mockRequestFromFile('/api/rules/search', 'search.json');
+        lib.mockRequestFromFile('/api/rules/show', 'show.json');
+        lib.mockRequest('/api/issues/search', '{}');
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rule.selected', function () {
+          casper.click('.coding-rule.selected .js-rule');
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rules-detail-header');
+      })
+
+      .then(function () {
+        test.assertExist('#coding-rules-quality-profile-activate');
+        casper.click('#coding-rules-quality-profile-activate');
+        casper.waitForSelector('.modal');
+      })
+
+      .then(function () {
+        test.assertExists('.modal .message-notice');
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/app.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/app.json
new file mode 100644 (file)
index 0000000..439f0fa
--- /dev/null
@@ -0,0 +1,110 @@
+{
+  "canWrite": true,
+  "qualityprofiles": [
+    {
+      "key": "java-default-with-mojo-conventions-49307",
+      "name": "Default - Maven Conventions",
+      "lang": "java",
+      "parentKey": "java-top-profile-without-formatting-conventions-50037"
+    }
+  ],
+  "languages": {
+    "py": "Python",
+    "js": "JavaScript",
+    "php": "PHP",
+    "java": "Java"
+  },
+  "repositories": [
+    {
+      "key": "common-java",
+      "name": "Common SonarQube",
+      "language": "java"
+    },
+    {
+      "key": "common-js",
+      "name": "Common SonarQube",
+      "language": "js"
+    },
+    {
+      "key": "common-php",
+      "name": "Common SonarQube",
+      "language": "php"
+    },
+    {
+      "key": "common-py",
+      "name": "Common SonarQube",
+      "language": "py"
+    },
+    {
+      "key": "Pylint",
+      "name": "Pylint",
+      "language": "py"
+    },
+    {
+      "key": "javascript",
+      "name": "SonarQube",
+      "language": "js"
+    },
+    {
+      "key": "php",
+      "name": "SonarQube",
+      "language": "php"
+    },
+    {
+      "key": "python",
+      "name": "SonarQube",
+      "language": "py"
+    },
+    {
+      "key": "squid",
+      "name": "SonarQube",
+      "language": "java"
+    }
+  ],
+  "statuses": {
+    "BETA": "Beta",
+    "DEPRECATED": "Deprecated",
+    "READY": "Ready"
+  },
+  "characteristics": {
+    "UNDERSTANDABILITY": "Maintainability: Understandability",
+    "MAINTAINABILITY": "Maintainability",
+    "TIME_ZONE_RELATED_PORTABILITY": "Portability: Time zone related portability",
+    "READABILITY": "Maintainability: Readability",
+    "SECURITY_FEATURES": "Security: Security features",
+    "ARCHITECTURE_RELIABILITY": "Reliability: Architecture related reliability",
+    "OS_RELATED_PORTABILITY": "Portability: OS related portability",
+    "EXCEPTION_HANDLING": "Reliability: Exception handling",
+    "LOGIC_CHANGEABILITY": "Changeability: Logic related changeability",
+    "SOFTWARE_RELATED_PORTABILITY": "Portability: Software related portability",
+    "INPUT_VALIDATION_AND_REPRESENTATION": "Security: Input validation and representation",
+    "LANGUAGE_RELATED_PORTABILITY": "Portability: Language related portability",
+    "ERRORS": "Security: Errors",
+    "SECURITY": "Security",
+    "RELIABILITY": "Reliability",
+    "PORTABILITY": "Portability",
+    "HARDWARE_RELATED_PORTABILITY": "Portability: Hardware related portability",
+    "SYNCHRONIZATION_RELIABILITY": "Reliability: Synchronization related reliability",
+    "TRANSPORTABILITY": "Reusability: Transportability",
+    "COMPILER_RELATED_PORTABILITY": "Portability: Compiler related portability",
+    "RESOURCE_RELIABILITY": "Reliability: Resource",
+    "CPU_EFFICIENCY": "Efficiency: Processor use",
+    "EFFICIENCY": "Efficiency",
+    "CHANGEABILITY": "Changeability",
+    "DATA_CHANGEABILITY": "Changeability: Data related changeability",
+    "API_ABUSE": "Security: API abuse",
+    "ARCHITECTURE_CHANGEABILITY": "Changeability: Architecture related changeability",
+    "UNIT_TESTS": "Reliability: Unit tests",
+    "INSTRUCTION_RELIABILITY": "Reliability: Instruction related reliability",
+    "REUSABILITY": "Reusability",
+    "MODULARITY": "Reusability: Modularity",
+    "UNIT_TESTABILITY": "Testability: Unit level testability",
+    "TESTABILITY": "Testability",
+    "INTEGRATION_TESTABILITY": "Testability: Integration level testability",
+    "NETWORK_USE": "Efficiency: Network use",
+    "MEMORY_EFFICIENCY": "Efficiency: Memory use",
+    "DATA_RELIABILITY": "Reliability: Data related reliability",
+    "FAULT_TOLERANCE": "Reliability: Fault tolerance",
+    "LOGIC_RELIABILITY": "Reliability: Logic related reliability"
+  }
+}
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/search.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/search.json
new file mode 100644 (file)
index 0000000..b5a6bc2
--- /dev/null
@@ -0,0 +1,171 @@
+{
+  "total": 10,
+  "p": 1,
+  "ps": 200,
+  "rules": [
+    {
+      "key": "squid:S1181",
+      "name": "Throwable and Error classes should not be caught",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "error-handling"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S1849",
+      "name": "\"Iterator.hasNext()\" should not call \"Iterator.next()\"",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "bug"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S1844",
+      "name": "\"Object.wait(...)\" should never be called on objects that implement \"java.util.concurrent.locks.Condition\"",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "bug",
+        "pitfall"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S2258",
+      "name": "\"javax.crypto.NullCipher\" should not be used for anything other than testing",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S2251",
+      "name": "A \"for\" loop update clause should move the counter in the right direction",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "bug"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:ObjectFinalizeOverridenCallsSuperFinalizeCheck",
+      "name": "super.finalize() should be called at the end of Object.finalize() implementations",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "bug"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S1143",
+      "name": "Return statements should not occur in finally blocks",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "bug"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S1206",
+      "name": "\"equals(Object obj)\" and \"hashCode()\" should be overridden in pairs",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "bug"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S1451",
+      "name": "Copyright and license headers should be defined in all source files",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "convention"
+      ],
+      "tags": []
+    },
+    {
+      "key": "squid:S1697",
+      "name": "Short-circuit logic should be used to prevent null pointer dereferences in conditionals",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "bug"
+      ],
+      "tags": []
+    }
+  ],
+  "facets": [
+    {
+      "property": "tags",
+      "values": [
+        {
+          "val": "bug",
+          "count": 7
+        },
+        {
+          "val": "convention",
+          "count": 1
+        },
+        {
+          "val": "cwe",
+          "count": 1
+        },
+        {
+          "val": "error-handling",
+          "count": 1
+        },
+        {
+          "val": "owasp-top10",
+          "count": 1
+        },
+        {
+          "val": "pitfall",
+          "count": 1
+        },
+        {
+          "val": "security",
+          "count": 1
+        }
+      ]
+    },
+    {
+      "property": "languages",
+      "values": [
+        {
+          "val": "java",
+          "count": 10
+        },
+        {
+          "val": "js",
+          "count": 6
+        },
+        {
+          "val": "php",
+          "count": 2
+        }
+      ]
+    },
+    {
+      "property": "repositories",
+      "values": [
+        {
+          "val": "squid",
+          "count": 10
+        }
+      ]
+    }
+  ]
+}
diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/show.json b/server/sonar-web/src/main/js/tests/e2e/tests/coding-rules-page-no-available-profiles-for-activation/show.json
new file mode 100644 (file)
index 0000000..1fddeb6
--- /dev/null
@@ -0,0 +1,39 @@
+{
+  "rule": {
+    "key": "squid:S1181",
+    "repo": "squid",
+    "name": "Throwable and Error classes should not be caught",
+    "createdAt": "2013-08-09T14:40:54+0200",
+    "severity": "BLOCKER",
+    "status": "READY",
+    "internalKey": "S1181",
+    "isTemplate": false,
+    "tags": [],
+    "sysTags": [
+      "error-handling"
+    ],
+    "lang": "java",
+    "langName": "Java",
+    "htmlDesc": "<p>\n<code>Throwable</code> is the superclass of all errors and exceptions in Java.\n<code>Error</code> is the superclass of all errors which are not meant to be caught by applications.\n</p>\n\n<p>\nCatching either <code>Throwable</code> or <code>Error</code> will also catch <code>OutOfMemoryError</code> or <code>InternalError</code> from which an application should not attempt to recover.\n</p>\n\n<p>Only <code>Exception</code> and its subclasses should be caught.</p>\n\n<h2>Noncompliant Code Example</h2>\n\n<pre>\ntry { /* ... */ } catch (Throwable t) { /* ... */ }\ntry { /* ... */ } catch (Error e) { /* ... */ } \n</pre>\n\n<h2>Compliant Solution</h2>\n\n<pre>\ntry { /* ... */ } catch (Exception e) { /* ... */ }  \ntry { /* ... */ } catch (RuntimeException e) { /* ... */ }  \ntry { /* ... */ } catch (MyException e) { /* ... */ }  \n</pre>",
+    "defaultDebtChar": "RELIABILITY",
+    "defaultDebtSubChar": "EXCEPTION_HANDLING",
+    "debtChar": "RELIABILITY",
+    "debtSubChar": "EXCEPTION_HANDLING",
+    "debtCharName": "Reliability",
+    "debtSubCharName": "Exception handling",
+    "defaultDebtRemFnType": "CONSTANT_ISSUE",
+    "defaultDebtRemFnOffset": "20min",
+    "debtOverloaded": true,
+    "debtRemFnType": "LINEAR",
+    "debtRemFnCoeff": "20min",
+    "params": []
+  },
+  "actives": [
+    {
+      "qProfile": "java-default-with-mojo-conventions-49307",
+      "inherit": "NONE",
+      "severity": "BLOCKER",
+      "params": []
+    }
+  ]
+}
index 7db54b195d9735e991b254ea1f4ffad93d01bc46..6f311418b8c18d87a573d71063012235e63fcbad 100644 (file)
@@ -1767,6 +1767,7 @@ rules.status.ready=Ready
 # CODING RULES
 #
 #------------------------------------------------------------------------------
+coding_rules.active_in_all_profiles=The rule is already activated on all available quality profiles.
 coding_rules.activate=Activate
 coding_rules.activate_in=Activate In
 coding_rules.activate_in_quality_profile=Activate In Quality Profile