{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments/103695398","pull_request_review_id":24489711,"id":103695398,"diff_hunk":"@@ -20,36 +20,66 @@\n package org.sonar.scanner.phases;\n \n import com.google.common.collect.Lists;\n+import java.util.ArrayList;\n+import java.util.Collection;\n+import java.util.Collections;\n import org.sonar.api.batch.ScannerSide;\n import org.sonar.api.batch.Sensor;\n import org.sonar.api.batch.SensorContext;\n import org.sonar.api.batch.fs.internal.DefaultInputModule;\n import org.sonar.api.resources.Project;\n import org.sonar.scanner.bootstrap.ScannerExtensionDictionnary;\n import org.sonar.scanner.events.EventBus;\n-import java.util.Collection;\n+import org.sonar.scanner.sensor.SensorStrategy;\n \n @ScannerSide\n public class SensorsExecutor {\n-  private final EventBus eventBus;\n-  private final DefaultInputModule module;\n   private final ScannerExtensionDictionnary selector;\n+  private final DefaultInputModule module;\n+  private final EventBus eventBus;\n+  private final SensorStrategy strategy;\n+  private final boolean isRoot;\n \n-  public SensorsExecutor(ScannerExtensionDictionnary selector, DefaultInputModule module, EventBus eventBus) {\n+  public SensorsExecutor(ScannerExtensionDictionnary selector, DefaultInputModule module, EventBus eventBus, SensorStrategy strategy) {\n     this.selector = selector;\n-    this.eventBus = eventBus;\n     this.module = module;\n+    this.eventBus = eventBus;\n+    this.strategy = strategy;\n+    this.isRoot = module.definition().getParent() == null;\n   }\n \n   public void execute(SensorContext context) {\n-    Collection<Sensor> sensors = selector.select(Sensor.class, module, true, null);\n-    eventBus.fireEvent(new SensorsPhaseEvent(Lists.newArrayList(sensors), true));\n+    Collection<Sensor> perModuleSensors = selector.selectSensors(module, false);\n+    Collection<Sensor> globalSensors;\n+    if (isRoot) {\n+      boolean orig = strategy.isGlobal();\n+      strategy.setGlobal(true);\n+      globalSensors = selector.selectSensors(module, true);\n+      strategy.setGlobal(orig);\n+    } else {\n+      globalSensors = Collections.emptyList();\n+    }\n+\n+    Collection<Sensor> allSensors = new ArrayList<>(perModuleSensors);\n+    allSensors.addAll(globalSensors);\n+    eventBus.fireEvent(new SensorsPhaseEvent(Lists.newArrayList(allSensors), true));\n+\n+    execute(context, perModuleSensors);\n+\n+    if (isRoot) {\n+      boolean orig = strategy.isGlobal();\n+      strategy.setGlobal(true);\n+      execute(context, globalSensors);\n+      strategy.setGlobal(orig);\n+    }\n+\n+    eventBus.fireEvent(new SensorsPhaseEvent(Lists.newArrayList(allSensors), false));\n+  }\n \n+  private void execute(SensorContext context, Collection<Sensor> sensors) {","path":"sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/SensorsExecutor.java","position":67,"original_position":67,"commit_id":"4b80c3161cfb0951ecea482b9b2785ac5a0aca5b","original_commit_id":"4b80c3161cfb0951ecea482b9b2785ac5a0aca5b","user":{"login":"SonarTech","id":1842438,"avatar_url":"https://avatars1.githubusercontent.com/u/1842438?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarTech","html_url":"https://github.com/SonarTech","followers_url":"https://api.github.com/users/SonarTech/followers","following_url":"https://api.github.com/users/SonarTech/following{/other_user}","gists_url":"https://api.github.com/users/SonarTech/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarTech/subscriptions","organizations_url":"https://api.github.com/users/SonarTech/orgs","repos_url":"https://api.github.com/users/SonarTech/repos","events_url":"https://api.github.com/users/SonarTech/events{/privacy}","received_events_url":"https://api.github.com/users/SonarTech/received_events","type":"User","site_admin":false},"body":"![MINOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-minor.png 'Severity: MINOR') Remove this use of \"SensorContext\"; it is deprecated. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3ACallToDeprecatedMethod)\n![MINOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-minor.png 'Severity: MINOR') Remove this use of \"Sensor\"; it is deprecated. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3ACallToDeprecatedMethod)\n","created_at":"2017-03-01T14:30:51Z","updated_at":"2017-03-01T14:30:51Z","html_url":"https://github.com/SonarSource/sonarqube/pull/1720#discussion_r103695398","pull_request_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments/103695398"},"html":{"href":"https://github.com/SonarSource/sonarqube/pull/1720#discussion_r103695398"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720","id":108341609,"html_url":"https://github.com/SonarSource/sonarqube/pull/1720","diff_url":"https://github.com/SonarSource/sonarqube/pull/1720.diff","patch_url":"https://github.com/SonarSource/sonarqube/pull/1720.patch","issue_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/1720","number":1720,"state":"open","locked":false,"title":"SONAR-8832 Support project-level sensors","user":{"login":"janos-ss","id":21700885,"avatar_url":"https://avatars3.githubusercontent.com/u/21700885?v=3","gravatar_id":"","url":"https://api.github.com/users/janos-ss","html_url":"https://github.com/janos-ss","followers_url":"https://api.github.com/users/janos-ss/followers","following_url":"https://api.github.com/users/janos-ss/following{/other_user}","gists_url":"https://api.github.com/users/janos-ss/gists{/gist_id}","starred_url":"https://api.github.com/users/janos-ss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janos-ss/subscriptions","organizations_url":"https://api.github.com/users/janos-ss/orgs","repos_url":"https://api.github.com/users/janos-ss/repos","events_url":"https://api.github.com/users/janos-ss/events{/privacy}","received_events_url":"https://api.github.com/users/janos-ss/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-02-28T14:32:28Z","updated_at":"2017-03-01T14:30:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ef62b4bbdd6f0c46c4d89505bad7d377611b412","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720/comments","review_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/1720/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/4b80c3161cfb0951ecea482b9b2785ac5a0aca5b","head":{"label":"SonarSource:project-scope-sensors","ref":"project-scope-sensors","sha":"4b80c3161cfb0951ecea482b9b2785ac5a0aca5b","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":1222504,"name":"sonarqube","full_name":"SonarSource/sonarqube","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarqube","description":"Continuous Code Quality","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarqube","forks_url":"https://api.github.com/repos/SonarSource/sonarqube/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarqube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarqube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarqube/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarqube/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarqube/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarqube/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarqube/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarqube/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarqube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarqube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarqube/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarqube/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarqube/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarqube/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarqube/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarqube/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarqube/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarqube/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarqube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarqube/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarqube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarqube/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarqube/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarqube/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarqube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarqube/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarqube/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarqube/deployments","created_at":"2011-01-05T11:05:17Z","updated_at":"2017-03-01T13:42:00Z","pushed_at":"2017-03-01T14:22:45Z","git_url":"git://github.com/SonarSource/sonarqube.git","ssh_url":"git@github.com:SonarSource/sonarqube.git","clone_url":"https://github.com/SonarSource/sonarqube.git","svn_url":"https://github.com/SonarSource/sonarqube","homepage":"http://www.sonarqube.org","size":154387,"stargazers_count":1557,"watchers_count":1557,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":592,"mirror_url":null,"open_issues_count":14,"forks":592,"open_issues":14,"watchers":1557,"default_branch":"master"}},"base":{"label":"SonarSource:master","ref":"master","sha":"8bc3795d4f94a477ea78d0b464d323ef6877fde0","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":1222504,"name":"sonarqube","full_name":"SonarSource/sonarqube","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars3.githubusercontent.com/u/545988?v=3","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarqube","description":"Continuous Code Quality","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarqube","forks_url":"https://api.github.com/repos/SonarSource/sonarqube/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarqube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarqube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarqube/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarqube/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarqube/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarqube/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarqube/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarqube/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarqube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarqube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarqube/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarqube/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarqube/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarqube/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarqube/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarqube/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarqube/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarqube/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarqube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarqube/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarqube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarqube/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarqube/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarqube/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarqube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarqube/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarqube/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarqube/deployments","created_at":"2011-01-05T11:05:17Z","updated_at":"2017-03-01T13:42:00Z","pushed_at":"2017-03-01T14:22:45Z","git_url":"git://github.com/SonarSource/sonarqube.git","ssh_url":"git@github.com:SonarSource/sonarqube.git","clone_url":"https://github.com/SonarSource/sonarqube.git","svn_url":"https://github.com/SonarSource/sonarqube","homepage":"http://www.sonarqube.org","size":154387,"stargazers_count":1557,"watchers_count":1557,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":592,"mirror_url":null,"open_issues_count":14,"forks":592,"open_issues":14,"watchers":1557,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720"},"html":{"href":"https://github.com/SonarSource/sonarqube/pull/1720"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonarqube/issues/1720"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonarqube/issues/1720/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/1720/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonarqube/statuses/4b80c3161cfb0951ecea482b9b2785ac5a0aca5b"}}}}
{"actor":{"display_login":"SonarTech"}}