{"action":"created","comment":{"url":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/comments/46352514","id":46352514,"diff_hunk":"@@ -156,34 +140,80 @@ protected function execute(InputInterface $input, OutputInterface $output)\n         $detector = new CouplingDetector($nodeParserResolver, $ruleChecker);\n \n         $violations = $detector->detect($finder, $rules);\n+        $this->outputViolations($output, $violations, $input->getOption('verbose'));\n+\n+        return $this->determineExitCode($violations);\n+    }\n \n-        if ('none' !== $displayMode) {\n-            $this->displayStandardViolations($output, $violations);\n+    /**\n+     * @param ViolationInterface[] $violations\n+     *\n+     * @return int\n+     */\n+    protected function determineExitCode(array $violations)\n+    {\n+        if (0 === count($violations)) {\n+            return 0;\n+        }\n+\n+        $exitCode = self::EXIT_WITH_WARNINGS;\n+        foreach ($violations as $violation) {\n+            if (ViolationInterface::TYPE_ERROR=== $violation->getType()) {\n+                $exitCode = self::EXIT_WITH_ERRORS;\n+                break;\n+            }\n         }\n \n-        return count($violations) > 0 ? 1 : 0;\n+        return $exitCode;\n     }\n \n     /**\n      * @param OutputInterface      $output\n      * @param ViolationInterface[] $violations\n+     * @param bool                 $verbose\n      */\n-    protected function displayStandardViolations(OutputInterface $output, array $violations)\n+    protected function outputViolations(OutputInterface $output, array $violations, $verbose = false)\n     {\n-        $totalCount = 0;\n+        $warningStyle = new OutputFormatterStyle('white', 'yellow', ['bold']);\n+        $output->getFormatter()->setStyle('warning', $warningStyle);\n+        $errorStyle = new OutputFormatterStyle('white', 'red', ['bold']);\n+        $output->getFormatter()->setStyle('error', $errorStyle);\n+\n+        $nbErrors = 0;\n         foreach ($violations as $violation) {\n             $rule = $violation->getRule();\n             $node = $violation->getNode();\n             $errorType = RuleInterface::TYPE_DISCOURAGED === $rule->getType() ? 'warning' : 'error';\n \n+            $msg = !$verbose ?\n+                sprintf(\n+                    'Rule <comment>%s</comment> violated in node <comment>%s</comment> by the tokens:',\n+                    $rule->getSubject(),\n+                    $node->getFilepath()\n+                ):\n+                sprintf(\n+                    'Rule <comment>%s</comment> (type %s with requirements: %s) violated in node <comment>%s</comment> by the tokens:',\n+                    $rule->getSubject(),\n+                    $rule->getType(),\n+                    implode(', ', $rule->getRequirements()),\n+                    $node->getFilepath()","path":"src/Akeneo/CouplingDetector/Console/Command/DetectCommand.php","position":135,"original_position":135,"commit_id":"a0658609072230d73d94a0e621d86392ba92a3c8","original_commit_id":"a0658609072230d73d94a0e621d86392ba92a3c8","user":{"login":"nidup","id":2104359,"avatar_url":"https://avatars.githubusercontent.com/u/2104359?v=3","gravatar_id":"","url":"https://api.github.com/users/nidup","html_url":"https://github.com/nidup","followers_url":"https://api.github.com/users/nidup/followers","following_url":"https://api.github.com/users/nidup/following{/other_user}","gists_url":"https://api.github.com/users/nidup/gists{/gist_id}","starred_url":"https://api.github.com/users/nidup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nidup/subscriptions","organizations_url":"https://api.github.com/users/nidup/orgs","repos_url":"https://api.github.com/users/nidup/repos","events_url":"https://api.github.com/users/nidup/events{/privacy}","received_events_url":"https://api.github.com/users/nidup/received_events","type":"User","site_admin":false},"body":"would put rule description somewhere in case of verbose mode","created_at":"2015-12-01T22:52:46Z","updated_at":"2015-12-01T22:52:46Z","html_url":"https://github.com/akeneo/php-coupling-detector/pull/17#discussion_r46352514","pull_request_url":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/comments/46352514"},"html":{"href":"https://github.com/akeneo/php-coupling-detector/pull/17#discussion_r46352514"},"pull_request":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17","id":52301016,"html_url":"https://github.com/akeneo/php-coupling-detector/pull/17","diff_url":"https://github.com/akeneo/php-coupling-detector/pull/17.diff","patch_url":"https://github.com/akeneo/php-coupling-detector/pull/17.patch","issue_url":"https://api.github.com/repos/akeneo/php-coupling-detector/issues/17","number":17,"state":"open","locked":false,"title":"Detect command improvements","user":{"login":"jjanvier","id":3691804,"avatar_url":"https://avatars.githubusercontent.com/u/3691804?v=3","gravatar_id":"","url":"https://api.github.com/users/jjanvier","html_url":"https://github.com/jjanvier","followers_url":"https://api.github.com/users/jjanvier/followers","following_url":"https://api.github.com/users/jjanvier/following{/other_user}","gists_url":"https://api.github.com/users/jjanvier/gists{/gist_id}","starred_url":"https://api.github.com/users/jjanvier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjanvier/subscriptions","organizations_url":"https://api.github.com/users/jjanvier/orgs","repos_url":"https://api.github.com/users/jjanvier/repos","events_url":"https://api.github.com/users/jjanvier/events{/privacy}","received_events_url":"https://api.github.com/users/jjanvier/received_events","type":"User","site_admin":false},"body":"Fixes https://github.com/akeneo/php-coupling-detector/issues/10\r\n\r\nTODO:\r\n- [x] delete *display mode* option\r\n- [x] define an exit status\r\n- [x] rework the ouptut and the verbose mode\r\n- [x] delete *strict* option\r\n\r\nnew output, verbose enabled\r\n![detect](https://cloud.githubusercontent.com/assets/3691804/11516084/a2bde1ee-9881-11e5-927e-ef3db896796b.png)\r\n","created_at":"2015-12-01T19:08:00Z","updated_at":"2015-12-01T22:52:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59386cb7ba7c19e3d5ffb8dd60d0537e450b1d33","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17/commits","review_comments_url":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17/comments","review_comment_url":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akeneo/php-coupling-detector/issues/17/comments","statuses_url":"https://api.github.com/repos/akeneo/php-coupling-detector/statuses/a0658609072230d73d94a0e621d86392ba92a3c8","head":{"label":"jjanvier:display-modes","ref":"display-modes","sha":"a0658609072230d73d94a0e621d86392ba92a3c8","user":{"login":"jjanvier","id":3691804,"avatar_url":"https://avatars.githubusercontent.com/u/3691804?v=3","gravatar_id":"","url":"https://api.github.com/users/jjanvier","html_url":"https://github.com/jjanvier","followers_url":"https://api.github.com/users/jjanvier/followers","following_url":"https://api.github.com/users/jjanvier/following{/other_user}","gists_url":"https://api.github.com/users/jjanvier/gists{/gist_id}","starred_url":"https://api.github.com/users/jjanvier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjanvier/subscriptions","organizations_url":"https://api.github.com/users/jjanvier/orgs","repos_url":"https://api.github.com/users/jjanvier/repos","events_url":"https://api.github.com/users/jjanvier/events{/privacy}","received_events_url":"https://api.github.com/users/jjanvier/received_events","type":"User","site_admin":false},"repo":{"id":45404226,"name":"coupling-detector","full_name":"jjanvier/coupling-detector","owner":{"login":"jjanvier","id":3691804,"avatar_url":"https://avatars.githubusercontent.com/u/3691804?v=3","gravatar_id":"","url":"https://api.github.com/users/jjanvier","html_url":"https://github.com/jjanvier","followers_url":"https://api.github.com/users/jjanvier/followers","following_url":"https://api.github.com/users/jjanvier/following{/other_user}","gists_url":"https://api.github.com/users/jjanvier/gists{/gist_id}","starred_url":"https://api.github.com/users/jjanvier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjanvier/subscriptions","organizations_url":"https://api.github.com/users/jjanvier/orgs","repos_url":"https://api.github.com/users/jjanvier/repos","events_url":"https://api.github.com/users/jjanvier/events{/privacy}","received_events_url":"https://api.github.com/users/jjanvier/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jjanvier/coupling-detector","description":"","fork":true,"url":"https://api.github.com/repos/jjanvier/coupling-detector","forks_url":"https://api.github.com/repos/jjanvier/coupling-detector/forks","keys_url":"https://api.github.com/repos/jjanvier/coupling-detector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jjanvier/coupling-detector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jjanvier/coupling-detector/teams","hooks_url":"https://api.github.com/repos/jjanvier/coupling-detector/hooks","issue_events_url":"https://api.github.com/repos/jjanvier/coupling-detector/issues/events{/number}","events_url":"https://api.github.com/repos/jjanvier/coupling-detector/events","assignees_url":"https://api.github.com/repos/jjanvier/coupling-detector/assignees{/user}","branches_url":"https://api.github.com/repos/jjanvier/coupling-detector/branches{/branch}","tags_url":"https://api.github.com/repos/jjanvier/coupling-detector/tags","blobs_url":"https://api.github.com/repos/jjanvier/coupling-detector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jjanvier/coupling-detector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jjanvier/coupling-detector/git/refs{/sha}","trees_url":"https://api.github.com/repos/jjanvier/coupling-detector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jjanvier/coupling-detector/statuses/{sha}","languages_url":"https://api.github.com/repos/jjanvier/coupling-detector/languages","stargazers_url":"https://api.github.com/repos/jjanvier/coupling-detector/stargazers","contributors_url":"https://api.github.com/repos/jjanvier/coupling-detector/contributors","subscribers_url":"https://api.github.com/repos/jjanvier/coupling-detector/subscribers","subscription_url":"https://api.github.com/repos/jjanvier/coupling-detector/subscription","commits_url":"https://api.github.com/repos/jjanvier/coupling-detector/commits{/sha}","git_commits_url":"https://api.github.com/repos/jjanvier/coupling-detector/git/commits{/sha}","comments_url":"https://api.github.com/repos/jjanvier/coupling-detector/comments{/number}","issue_comment_url":"https://api.github.com/repos/jjanvier/coupling-detector/issues/comments{/number}","contents_url":"https://api.github.com/repos/jjanvier/coupling-detector/contents/{+path}","compare_url":"https://api.github.com/repos/jjanvier/coupling-detector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jjanvier/coupling-detector/merges","archive_url":"https://api.github.com/repos/jjanvier/coupling-detector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jjanvier/coupling-detector/downloads","issues_url":"https://api.github.com/repos/jjanvier/coupling-detector/issues{/number}","pulls_url":"https://api.github.com/repos/jjanvier/coupling-detector/pulls{/number}","milestones_url":"https://api.github.com/repos/jjanvier/coupling-detector/milestones{/number}","notifications_url":"https://api.github.com/repos/jjanvier/coupling-detector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jjanvier/coupling-detector/labels{/name}","releases_url":"https://api.github.com/repos/jjanvier/coupling-detector/releases{/id}","created_at":"2015-11-02T15:47:04Z","updated_at":"2015-11-02T15:47:05Z","pushed_at":"2015-12-01T22:38:55Z","git_url":"git://github.com/jjanvier/coupling-detector.git","ssh_url":"git@github.com:jjanvier/coupling-detector.git","clone_url":"https://github.com/jjanvier/coupling-detector.git","svn_url":"https://github.com/jjanvier/coupling-detector","homepage":null,"size":84,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"akeneo:master","ref":"master","sha":"6a36255c3e0d96be8f9546cbd86649238034e038","user":{"login":"akeneo","id":2510186,"avatar_url":"https://avatars.githubusercontent.com/u/2510186?v=3","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"repo":{"id":15440415,"name":"php-coupling-detector","full_name":"akeneo/php-coupling-detector","owner":{"login":"akeneo","id":2510186,"avatar_url":"https://avatars.githubusercontent.com/u/2510186?v=3","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akeneo/php-coupling-detector","description":"[WIP] Detects PHP coupling issues","fork":false,"url":"https://api.github.com/repos/akeneo/php-coupling-detector","forks_url":"https://api.github.com/repos/akeneo/php-coupling-detector/forks","keys_url":"https://api.github.com/repos/akeneo/php-coupling-detector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akeneo/php-coupling-detector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akeneo/php-coupling-detector/teams","hooks_url":"https://api.github.com/repos/akeneo/php-coupling-detector/hooks","issue_events_url":"https://api.github.com/repos/akeneo/php-coupling-detector/issues/events{/number}","events_url":"https://api.github.com/repos/akeneo/php-coupling-detector/events","assignees_url":"https://api.github.com/repos/akeneo/php-coupling-detector/assignees{/user}","branches_url":"https://api.github.com/repos/akeneo/php-coupling-detector/branches{/branch}","tags_url":"https://api.github.com/repos/akeneo/php-coupling-detector/tags","blobs_url":"https://api.github.com/repos/akeneo/php-coupling-detector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akeneo/php-coupling-detector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akeneo/php-coupling-detector/git/refs{/sha}","trees_url":"https://api.github.com/repos/akeneo/php-coupling-detector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akeneo/php-coupling-detector/statuses/{sha}","languages_url":"https://api.github.com/repos/akeneo/php-coupling-detector/languages","stargazers_url":"https://api.github.com/repos/akeneo/php-coupling-detector/stargazers","contributors_url":"https://api.github.com/repos/akeneo/php-coupling-detector/contributors","subscribers_url":"https://api.github.com/repos/akeneo/php-coupling-detector/subscribers","subscription_url":"https://api.github.com/repos/akeneo/php-coupling-detector/subscription","commits_url":"https://api.github.com/repos/akeneo/php-coupling-detector/commits{/sha}","git_commits_url":"https://api.github.com/repos/akeneo/php-coupling-detector/git/commits{/sha}","comments_url":"https://api.github.com/repos/akeneo/php-coupling-detector/comments{/number}","issue_comment_url":"https://api.github.com/repos/akeneo/php-coupling-detector/issues/comments{/number}","contents_url":"https://api.github.com/repos/akeneo/php-coupling-detector/contents/{+path}","compare_url":"https://api.github.com/repos/akeneo/php-coupling-detector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akeneo/php-coupling-detector/merges","archive_url":"https://api.github.com/repos/akeneo/php-coupling-detector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akeneo/php-coupling-detector/downloads","issues_url":"https://api.github.com/repos/akeneo/php-coupling-detector/issues{/number}","pulls_url":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls{/number}","milestones_url":"https://api.github.com/repos/akeneo/php-coupling-detector/milestones{/number}","notifications_url":"https://api.github.com/repos/akeneo/php-coupling-detector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akeneo/php-coupling-detector/labels{/name}","releases_url":"https://api.github.com/repos/akeneo/php-coupling-detector/releases{/id}","created_at":"2013-12-25T20:51:03Z","updated_at":"2015-12-01T18:48:49Z","pushed_at":"2015-12-01T22:38:55Z","git_url":"git://github.com/akeneo/php-coupling-detector.git","ssh_url":"git@github.com:akeneo/php-coupling-detector.git","clone_url":"https://github.com/akeneo/php-coupling-detector.git","svn_url":"https://github.com/akeneo/php-coupling-detector","homepage":"","size":89,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":9,"forks":1,"open_issues":9,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17"},"html":{"href":"https://github.com/akeneo/php-coupling-detector/pull/17"},"issue":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/issues/17"},"comments":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/akeneo/php-coupling-detector/statuses/a0658609072230d73d94a0e621d86392ba92a3c8"}}}}