{"action":"created","comment":{"url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/comments/67053425","id":67053425,"diff_hunk":"@@ -25,8 +43,73 @@ public void define(Context context) {\n         NewRepository repository = context\n                 .createRepository(CheckList.REPOSITORY_KEY, Apex.KEY)\n                 .setName(CheckList.REPOSITORY_NAME);\n-\n-        AnnotationBasedRulesDefinition.load(repository, Apex.KEY, CheckList.getChecks());\n+        List<Class> checks = CheckList.getChecks();\n+        new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class));\n+        checks.stream().forEach((ruleClass) -> {\n+            newRule(ruleClass, repository);\n+        });\n         repository.done();\n     }\n+\n+    @VisibleForTesting\n+    protected void newRule(Class<?> ruleClass, NewRepository repository) {\n+        org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(ruleClass, org.sonar.check.Rule.class);\n+        if (ruleAnnotation == null) {\n+            throw new IllegalArgumentException(\"No Rule annotation was found on \" + ruleClass);\n+        }\n+        String ruleKey = ruleAnnotation.key();\n+        if (StringUtils.isEmpty(ruleKey)) {\n+            throw new IllegalArgumentException(\"No key is defined in Rule annotation of \" + ruleClass);\n+        }\n+        NewRule rule = repository.rule(ruleKey);\n+        if (rule == null) {\n+            throw new IllegalStateException(\"No rule was created for \" + ruleClass + \" in \" + repository.key());\n+        }\n+\n+        addHtmlDescription(rule, rule.key());\n+        addMetadata(rule, rule.key());\n+    }\n+\n+    private void addMetadata(NewRule rule, String metadataKey) {\n+        URL resource = ExternalDescriptionLoader.class.getResource(RESOURCE_BASE_PATH + \"/\" + metadataKey + \".json\");\n+        if (resource != null) {\n+            RuleMetatada metadata = gson.fromJson(readResource(resource), RuleMetatada.class);\n+            rule.setName(metadata.title);\n+            rule.setSeverity(metadata.defaultSeverity.toUpperCase());\n+            rule.addTags(metadata.tags);\n+            rule.setStatus(RuleStatus.valueOf(metadata.status.toUpperCase()));\n+            rule.setDebtSubCharacteristic(metadata.sqaleSubCharac);\n+            if (metadata.remediation != null) {\n+                rule.setDebtRemediationFunction(metadata.remediation.remediationFunction(rule.debtRemediationFunctions()));\n+                rule.setEffortToFixDescription(metadata.remediation.linearDesc);\n+            }\n+        }\n+    }\n+\n+    private static void addHtmlDescription(NewRule rule, String metadataKey) {\n+        URL resource = ApexRulesDefinition.class.getResource(RESOURCE_BASE_PATH + \"/\" + metadataKey + \".html\");\n+        if (resource != null) {\n+            rule.setHtmlDescription(readResource(resource));\n+        }\n+    }\n+\n+    private static String readResource(URL resource) {\n+        try {\n+            return Resources.toString(resource, Charsets.UTF_8);\n+        } catch (IOException e) {\n+            throw new IllegalStateException(\"Failed to read: \" + resource, e);\n+        }\n+    }\n+\n+    private static class RuleMetatada {\n+\n+        String title;\n+        String status;\n+        @Nullable\n+        Remediation remediation;\n+\n+        String sqaleSubCharac;","path":"sonar-apex-plugin/src/main/java/org/fundacionjala/enforce/sonarqube/apex/rules/ApexRulesDefinition.java","position":111,"original_position":111,"commit_id":"e215c4be62f5c467bec10b446050d1ad12775a98","original_commit_id":"e215c4be62f5c467bec10b446050d1ad12775a98","user":{"login":"JimmyRojas","id":13870974,"avatar_url":"https://avatars.githubusercontent.com/u/13870974?v=3","gravatar_id":"","url":"https://api.github.com/users/JimmyRojas","html_url":"https://github.com/JimmyRojas","followers_url":"https://api.github.com/users/JimmyRojas/followers","following_url":"https://api.github.com/users/JimmyRojas/following{/other_user}","gists_url":"https://api.github.com/users/JimmyRojas/gists{/gist_id}","starred_url":"https://api.github.com/users/JimmyRojas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimmyRojas/subscriptions","organizations_url":"https://api.github.com/users/JimmyRojas/orgs","repos_url":"https://api.github.com/users/JimmyRojas/repos","events_url":"https://api.github.com/users/JimmyRojas/events{/privacy}","received_events_url":"https://api.github.com/users/JimmyRojas/received_events","type":"User","site_admin":false},"body":"can we be more descriptive regarding naming convention?","created_at":"2016-06-14T20:47:12Z","updated_at":"2016-06-14T20:47:12Z","html_url":"https://github.com/fundacionjala/enforce-sonarqube-plugin/pull/75#discussion_r67053425","pull_request_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75","_links":{"self":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/comments/67053425"},"html":{"href":"https://github.com/fundacionjala/enforce-sonarqube-plugin/pull/75#discussion_r67053425"},"pull_request":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75"}}},"pull_request":{"url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75","id":73796629,"html_url":"https://github.com/fundacionjala/enforce-sonarqube-plugin/pull/75","diff_url":"https://github.com/fundacionjala/enforce-sonarqube-plugin/pull/75.diff","patch_url":"https://github.com/fundacionjala/enforce-sonarqube-plugin/pull/75.patch","issue_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/issues/75","number":75,"state":"open","locked":false,"title":"Checks information is being recovered from a json file","user":{"login":"kevinTveizaga","id":4600689,"avatar_url":"https://avatars.githubusercontent.com/u/4600689?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinTveizaga","html_url":"https://github.com/kevinTveizaga","followers_url":"https://api.github.com/users/kevinTveizaga/followers","following_url":"https://api.github.com/users/kevinTveizaga/following{/other_user}","gists_url":"https://api.github.com/users/kevinTveizaga/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinTveizaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinTveizaga/subscriptions","organizations_url":"https://api.github.com/users/kevinTveizaga/orgs","repos_url":"https://api.github.com/users/kevinTveizaga/repos","events_url":"https://api.github.com/users/kevinTveizaga/events{/privacy}","received_events_url":"https://api.github.com/users/kevinTveizaga/received_events","type":"User","site_admin":false},"body":"Rules for checks now are being activated from a json file","created_at":"2016-06-14T19:11:57Z","updated_at":"2016-06-14T20:47:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5127179c0cb0a8d6b3d8a27b2bf5ca6b064b632d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75/commits","review_comments_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75/comments","review_comment_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/issues/75/comments","statuses_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/statuses/e215c4be62f5c467bec10b446050d1ad12775a98","head":{"label":"kevinTveizaga:CHECKS_INFORMATION_IN_A_FILE","ref":"CHECKS_INFORMATION_IN_A_FILE","sha":"e215c4be62f5c467bec10b446050d1ad12775a98","user":{"login":"kevinTveizaga","id":4600689,"avatar_url":"https://avatars.githubusercontent.com/u/4600689?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinTveizaga","html_url":"https://github.com/kevinTveizaga","followers_url":"https://api.github.com/users/kevinTveizaga/followers","following_url":"https://api.github.com/users/kevinTveizaga/following{/other_user}","gists_url":"https://api.github.com/users/kevinTveizaga/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinTveizaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinTveizaga/subscriptions","organizations_url":"https://api.github.com/users/kevinTveizaga/orgs","repos_url":"https://api.github.com/users/kevinTveizaga/repos","events_url":"https://api.github.com/users/kevinTveizaga/events{/privacy}","received_events_url":"https://api.github.com/users/kevinTveizaga/received_events","type":"User","site_admin":false},"repo":{"id":54072823,"name":"enforce-sonarqube-plugin","full_name":"kevinTveizaga/enforce-sonarqube-plugin","owner":{"login":"kevinTveizaga","id":4600689,"avatar_url":"https://avatars.githubusercontent.com/u/4600689?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinTveizaga","html_url":"https://github.com/kevinTveizaga","followers_url":"https://api.github.com/users/kevinTveizaga/followers","following_url":"https://api.github.com/users/kevinTveizaga/following{/other_user}","gists_url":"https://api.github.com/users/kevinTveizaga/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinTveizaga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinTveizaga/subscriptions","organizations_url":"https://api.github.com/users/kevinTveizaga/orgs","repos_url":"https://api.github.com/users/kevinTveizaga/repos","events_url":"https://api.github.com/users/kevinTveizaga/events{/privacy}","received_events_url":"https://api.github.com/users/kevinTveizaga/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kevinTveizaga/enforce-sonarqube-plugin","description":"Apex static code analyzer.","fork":true,"url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin","forks_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/forks","keys_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/teams","hooks_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/hooks","issue_events_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/events","assignees_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/tags","blobs_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/languages","stargazers_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/stargazers","contributors_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/contributors","subscribers_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/subscribers","subscription_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/subscription","commits_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/merges","archive_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/downloads","issues_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/labels{/name}","releases_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/kevinTveizaga/enforce-sonarqube-plugin/deployments","created_at":"2016-03-16T23:09:17Z","updated_at":"2016-03-04T18:59:21Z","pushed_at":"2016-06-14T19:06:47Z","git_url":"git://github.com/kevinTveizaga/enforce-sonarqube-plugin.git","ssh_url":"git@github.com:kevinTveizaga/enforce-sonarqube-plugin.git","clone_url":"https://github.com/kevinTveizaga/enforce-sonarqube-plugin.git","svn_url":"https://github.com/kevinTveizaga/enforce-sonarqube-plugin","homepage":null,"size":1305,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fundacionjala:develop","ref":"develop","sha":"f71adfdb72582fe0dba2fc5519971e2869c93bc2","user":{"login":"fundacionjala","id":11635305,"avatar_url":"https://avatars.githubusercontent.com/u/11635305?v=3","gravatar_id":"","url":"https://api.github.com/users/fundacionjala","html_url":"https://github.com/fundacionjala","followers_url":"https://api.github.com/users/fundacionjala/followers","following_url":"https://api.github.com/users/fundacionjala/following{/other_user}","gists_url":"https://api.github.com/users/fundacionjala/gists{/gist_id}","starred_url":"https://api.github.com/users/fundacionjala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fundacionjala/subscriptions","organizations_url":"https://api.github.com/users/fundacionjala/orgs","repos_url":"https://api.github.com/users/fundacionjala/repos","events_url":"https://api.github.com/users/fundacionjala/events{/privacy}","received_events_url":"https://api.github.com/users/fundacionjala/received_events","type":"Organization","site_admin":false},"repo":{"id":50429558,"name":"enforce-sonarqube-plugin","full_name":"fundacionjala/enforce-sonarqube-plugin","owner":{"login":"fundacionjala","id":11635305,"avatar_url":"https://avatars.githubusercontent.com/u/11635305?v=3","gravatar_id":"","url":"https://api.github.com/users/fundacionjala","html_url":"https://github.com/fundacionjala","followers_url":"https://api.github.com/users/fundacionjala/followers","following_url":"https://api.github.com/users/fundacionjala/following{/other_user}","gists_url":"https://api.github.com/users/fundacionjala/gists{/gist_id}","starred_url":"https://api.github.com/users/fundacionjala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fundacionjala/subscriptions","organizations_url":"https://api.github.com/users/fundacionjala/orgs","repos_url":"https://api.github.com/users/fundacionjala/repos","events_url":"https://api.github.com/users/fundacionjala/events{/privacy}","received_events_url":"https://api.github.com/users/fundacionjala/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fundacionjala/enforce-sonarqube-plugin","description":"Apex static code analyzer.","fork":false,"url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin","forks_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/forks","keys_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/teams","hooks_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/hooks","issue_events_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/events","assignees_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/tags","blobs_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/languages","stargazers_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/stargazers","contributors_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/contributors","subscribers_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/subscribers","subscription_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/subscription","commits_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/merges","archive_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/downloads","issues_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/labels{/name}","releases_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/deployments","created_at":"2016-01-26T13:15:15Z","updated_at":"2016-05-13T17:41:06Z","pushed_at":"2016-06-14T19:11:58Z","git_url":"git://github.com/fundacionjala/enforce-sonarqube-plugin.git","ssh_url":"git@github.com:fundacionjala/enforce-sonarqube-plugin.git","clone_url":"https://github.com/fundacionjala/enforce-sonarqube-plugin.git","svn_url":"https://github.com/fundacionjala/enforce-sonarqube-plugin","homepage":null,"size":1455,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":13,"mirror_url":null,"open_issues_count":36,"forks":13,"open_issues":36,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75"},"html":{"href":"https://github.com/fundacionjala/enforce-sonarqube-plugin/pull/75"},"issue":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/issues/75"},"comments":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/issues/75/comments"},"review_comments":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75/comments"},"review_comment":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/pulls/75/commits"},"statuses":{"href":"https://api.github.com/repos/fundacionjala/enforce-sonarqube-plugin/statuses/e215c4be62f5c467bec10b446050d1ad12775a98"}}}}
{"actor":{"display_login":"JimmyRojas"}}