{"action":"created","comment":{"url":"https://api.github.com/repos/troessner/reek/pulls/comments/27947082","id":27947082,"diff_hunk":"@@ -14,41 +14,25 @@ module Configuration\n     # The order in which ConfigurationFileFinder tries to find such a\n     # configuration file is exactly like above.\n     module ConfigurationFileFinder\n-      class << self\n-        def find(options)\n-          configuration_by_cli(options) ||\n-            configuration_in_file_system    ||\n-            configuration_in_home_directory\n-        end\n-\n-        private\n-\n-        def configuration_by_cli(options)\n-          return unless options # Return gracefully allowing calls without app context\n-          config_file_option = options.config_file\n-          return unless config_file_option\n-          path_name = Pathname.new config_file_option\n-          raise ArgumentError, \"Config file #{path_name} doesn't exist\" unless path_name.exist?\n-          path_name\n-        end\n-\n-        def configuration_in_file_system\n-          detect_or_traverse_up Pathname.pwd\n-        end\n+      module_function\n \n-        def configuration_in_home_directory\n-          detect_configuration_in_directory Pathname.new(Dir.home)\n-        end\n+      # FIXME: switch to kwargs on upgrade to Ruby 2 and drop `dirs.fetch` calls:\n+      # def find(options, current: Pathname.pwd, home: Pathname.new(Dir.home))\n+      def find(options, dirs = {})\n+        current = dirs.fetch(:current) { Pathname.pwd           }\n+        home    = dirs.fetch(:home)    { Pathname.new(Dir.home) }\n+        find_by_cli(options) || find_by_dir(current) || find_by_dir(home)\n+      end\n \n-        def detect_or_traverse_up(directory)\n-          file = detect_configuration_in_directory(directory)\n-          return file unless file.nil?\n-          return if directory.root?\n-          detect_or_traverse_up directory.parent\n-        end\n+      def find_by_cli(options)\n+        options && options.config_file\n+      end\n \n-        def detect_configuration_in_directory(directory)\n-          directory.children.select(&:file?).find { |path| path.to_s.end_with?('.reek') }\n+      def find_by_dir(start)\n+        start.ascend do |dir|","path":"lib/reek/configuration/configuration_file_finder.rb","position":51,"original_position":51,"commit_id":"e803797dd9e62cc0decaef298a543c41e0275f3c","original_commit_id":"e803797dd9e62cc0decaef298a543c41e0275f3c","user":{"login":"troessner","id":271109,"avatar_url":"https://avatars.githubusercontent.com/u/271109?v=3","gravatar_id":"","url":"https://api.github.com/users/troessner","html_url":"https://github.com/troessner","followers_url":"https://api.github.com/users/troessner/followers","following_url":"https://api.github.com/users/troessner/following{/other_user}","gists_url":"https://api.github.com/users/troessner/gists{/gist_id}","starred_url":"https://api.github.com/users/troessner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troessner/subscriptions","organizations_url":"https://api.github.com/users/troessner/orgs","repos_url":"https://api.github.com/users/troessner/repos","events_url":"https://api.github.com/users/troessner/events{/privacy}","received_events_url":"https://api.github.com/users/troessner/received_events","type":"User","site_admin":false},"body":"Nice! I didn't know Pathname#ascend until now!","created_at":"2015-04-08T07:04:10Z","updated_at":"2015-04-08T07:04:10Z","html_url":"https://github.com/troessner/reek/pull/428#discussion_r27947082","pull_request_url":"https://api.github.com/repos/troessner/reek/pulls/428","_links":{"self":{"href":"https://api.github.com/repos/troessner/reek/pulls/comments/27947082"},"html":{"href":"https://github.com/troessner/reek/pull/428#discussion_r27947082"},"pull_request":{"href":"https://api.github.com/repos/troessner/reek/pulls/428"}}},"pull_request":{"url":"https://api.github.com/repos/troessner/reek/pulls/428","id":32793202,"html_url":"https://github.com/troessner/reek/pull/428","diff_url":"https://github.com/troessner/reek/pull/428.diff","patch_url":"https://github.com/troessner/reek/pull/428.patch","issue_url":"https://api.github.com/repos/troessner/reek/issues/428","number":428,"state":"open","locked":false,"title":"Refactor ConfigurationFileFinder and its spec","user":{"login":"chastell","id":56633,"avatar_url":"https://avatars.githubusercontent.com/u/56633?v=3","gravatar_id":"","url":"https://api.github.com/users/chastell","html_url":"https://github.com/chastell","followers_url":"https://api.github.com/users/chastell/followers","following_url":"https://api.github.com/users/chastell/following{/other_user}","gists_url":"https://api.github.com/users/chastell/gists{/gist_id}","starred_url":"https://api.github.com/users/chastell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chastell/subscriptions","organizations_url":"https://api.github.com/users/chastell/orgs","repos_url":"https://api.github.com/users/chastell/repos","events_url":"https://api.github.com/users/chastell/events{/privacy}","received_events_url":"https://api.github.com/users/chastell/received_events","type":"User","site_admin":false},"body":"Just an indea, let me know what you think. Technical changes: `Options#config_file` is now a `Pathname`, `ConfigurationFileFinder` now also parses from `$HOME` up (IMHO harmless – especially when we already go up to the root from the current dir – and makes the code simpler).","created_at":"2015-04-07T18:46:28Z","updated_at":"2015-04-08T07:04:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"06268537815981e592668a1ce66f5e697cc547af","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/troessner/reek/pulls/428/commits","review_comments_url":"https://api.github.com/repos/troessner/reek/pulls/428/comments","review_comment_url":"https://api.github.com/repos/troessner/reek/pulls/comments{/number}","comments_url":"https://api.github.com/repos/troessner/reek/issues/428/comments","statuses_url":"https://api.github.com/repos/troessner/reek/statuses/e803797dd9e62cc0decaef298a543c41e0275f3c","head":{"label":"troessner:better_ConfigurationFileFinder","ref":"better_ConfigurationFileFinder","sha":"e803797dd9e62cc0decaef298a543c41e0275f3c","user":{"login":"troessner","id":271109,"avatar_url":"https://avatars.githubusercontent.com/u/271109?v=3","gravatar_id":"","url":"https://api.github.com/users/troessner","html_url":"https://github.com/troessner","followers_url":"https://api.github.com/users/troessner/followers","following_url":"https://api.github.com/users/troessner/following{/other_user}","gists_url":"https://api.github.com/users/troessner/gists{/gist_id}","starred_url":"https://api.github.com/users/troessner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troessner/subscriptions","organizations_url":"https://api.github.com/users/troessner/orgs","repos_url":"https://api.github.com/users/troessner/repos","events_url":"https://api.github.com/users/troessner/events{/privacy}","received_events_url":"https://api.github.com/users/troessner/received_events","type":"User","site_admin":false},"repo":{"id":49515,"name":"reek","full_name":"troessner/reek","owner":{"login":"troessner","id":271109,"avatar_url":"https://avatars.githubusercontent.com/u/271109?v=3","gravatar_id":"","url":"https://api.github.com/users/troessner","html_url":"https://github.com/troessner","followers_url":"https://api.github.com/users/troessner/followers","following_url":"https://api.github.com/users/troessner/following{/other_user}","gists_url":"https://api.github.com/users/troessner/gists{/gist_id}","starred_url":"https://api.github.com/users/troessner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troessner/subscriptions","organizations_url":"https://api.github.com/users/troessner/orgs","repos_url":"https://api.github.com/users/troessner/repos","events_url":"https://api.github.com/users/troessner/events{/privacy}","received_events_url":"https://api.github.com/users/troessner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/troessner/reek","description":"Code smell detector for Ruby","fork":false,"url":"https://api.github.com/repos/troessner/reek","forks_url":"https://api.github.com/repos/troessner/reek/forks","keys_url":"https://api.github.com/repos/troessner/reek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/troessner/reek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/troessner/reek/teams","hooks_url":"https://api.github.com/repos/troessner/reek/hooks","issue_events_url":"https://api.github.com/repos/troessner/reek/issues/events{/number}","events_url":"https://api.github.com/repos/troessner/reek/events","assignees_url":"https://api.github.com/repos/troessner/reek/assignees{/user}","branches_url":"https://api.github.com/repos/troessner/reek/branches{/branch}","tags_url":"https://api.github.com/repos/troessner/reek/tags","blobs_url":"https://api.github.com/repos/troessner/reek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/troessner/reek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/troessner/reek/git/refs{/sha}","trees_url":"https://api.github.com/repos/troessner/reek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/troessner/reek/statuses/{sha}","languages_url":"https://api.github.com/repos/troessner/reek/languages","stargazers_url":"https://api.github.com/repos/troessner/reek/stargazers","contributors_url":"https://api.github.com/repos/troessner/reek/contributors","subscribers_url":"https://api.github.com/repos/troessner/reek/subscribers","subscription_url":"https://api.github.com/repos/troessner/reek/subscription","commits_url":"https://api.github.com/repos/troessner/reek/commits{/sha}","git_commits_url":"https://api.github.com/repos/troessner/reek/git/commits{/sha}","comments_url":"https://api.github.com/repos/troessner/reek/comments{/number}","issue_comment_url":"https://api.github.com/repos/troessner/reek/issues/comments{/number}","contents_url":"https://api.github.com/repos/troessner/reek/contents/{+path}","compare_url":"https://api.github.com/repos/troessner/reek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/troessner/reek/merges","archive_url":"https://api.github.com/repos/troessner/reek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/troessner/reek/downloads","issues_url":"https://api.github.com/repos/troessner/reek/issues{/number}","pulls_url":"https://api.github.com/repos/troessner/reek/pulls{/number}","milestones_url":"https://api.github.com/repos/troessner/reek/milestones{/number}","notifications_url":"https://api.github.com/repos/troessner/reek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/troessner/reek/labels{/name}","releases_url":"https://api.github.com/repos/troessner/reek/releases{/id}","created_at":"2008-09-05T10:48:33Z","updated_at":"2015-04-07T08:53:55Z","pushed_at":"2015-04-07T18:46:28Z","git_url":"git://github.com/troessner/reek.git","ssh_url":"git@github.com:troessner/reek.git","clone_url":"https://github.com/troessner/reek.git","svn_url":"https://github.com/troessner/reek","homepage":"https://github.com/troessner/reek/wiki","size":7006,"stargazers_count":1236,"watchers_count":1236,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":83,"mirror_url":null,"open_issues_count":21,"forks":83,"open_issues":21,"watchers":1236,"default_branch":"master"}},"base":{"label":"troessner:master","ref":"master","sha":"7ad005afdbc99129b67b414f8e6a85cd6013f8ec","user":{"login":"troessner","id":271109,"avatar_url":"https://avatars.githubusercontent.com/u/271109?v=3","gravatar_id":"","url":"https://api.github.com/users/troessner","html_url":"https://github.com/troessner","followers_url":"https://api.github.com/users/troessner/followers","following_url":"https://api.github.com/users/troessner/following{/other_user}","gists_url":"https://api.github.com/users/troessner/gists{/gist_id}","starred_url":"https://api.github.com/users/troessner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troessner/subscriptions","organizations_url":"https://api.github.com/users/troessner/orgs","repos_url":"https://api.github.com/users/troessner/repos","events_url":"https://api.github.com/users/troessner/events{/privacy}","received_events_url":"https://api.github.com/users/troessner/received_events","type":"User","site_admin":false},"repo":{"id":49515,"name":"reek","full_name":"troessner/reek","owner":{"login":"troessner","id":271109,"avatar_url":"https://avatars.githubusercontent.com/u/271109?v=3","gravatar_id":"","url":"https://api.github.com/users/troessner","html_url":"https://github.com/troessner","followers_url":"https://api.github.com/users/troessner/followers","following_url":"https://api.github.com/users/troessner/following{/other_user}","gists_url":"https://api.github.com/users/troessner/gists{/gist_id}","starred_url":"https://api.github.com/users/troessner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troessner/subscriptions","organizations_url":"https://api.github.com/users/troessner/orgs","repos_url":"https://api.github.com/users/troessner/repos","events_url":"https://api.github.com/users/troessner/events{/privacy}","received_events_url":"https://api.github.com/users/troessner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/troessner/reek","description":"Code smell detector for Ruby","fork":false,"url":"https://api.github.com/repos/troessner/reek","forks_url":"https://api.github.com/repos/troessner/reek/forks","keys_url":"https://api.github.com/repos/troessner/reek/keys{/key_id}","collaborators_url":"https://api.github.com/repos/troessner/reek/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/troessner/reek/teams","hooks_url":"https://api.github.com/repos/troessner/reek/hooks","issue_events_url":"https://api.github.com/repos/troessner/reek/issues/events{/number}","events_url":"https://api.github.com/repos/troessner/reek/events","assignees_url":"https://api.github.com/repos/troessner/reek/assignees{/user}","branches_url":"https://api.github.com/repos/troessner/reek/branches{/branch}","tags_url":"https://api.github.com/repos/troessner/reek/tags","blobs_url":"https://api.github.com/repos/troessner/reek/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/troessner/reek/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/troessner/reek/git/refs{/sha}","trees_url":"https://api.github.com/repos/troessner/reek/git/trees{/sha}","statuses_url":"https://api.github.com/repos/troessner/reek/statuses/{sha}","languages_url":"https://api.github.com/repos/troessner/reek/languages","stargazers_url":"https://api.github.com/repos/troessner/reek/stargazers","contributors_url":"https://api.github.com/repos/troessner/reek/contributors","subscribers_url":"https://api.github.com/repos/troessner/reek/subscribers","subscription_url":"https://api.github.com/repos/troessner/reek/subscription","commits_url":"https://api.github.com/repos/troessner/reek/commits{/sha}","git_commits_url":"https://api.github.com/repos/troessner/reek/git/commits{/sha}","comments_url":"https://api.github.com/repos/troessner/reek/comments{/number}","issue_comment_url":"https://api.github.com/repos/troessner/reek/issues/comments{/number}","contents_url":"https://api.github.com/repos/troessner/reek/contents/{+path}","compare_url":"https://api.github.com/repos/troessner/reek/compare/{base}...{head}","merges_url":"https://api.github.com/repos/troessner/reek/merges","archive_url":"https://api.github.com/repos/troessner/reek/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/troessner/reek/downloads","issues_url":"https://api.github.com/repos/troessner/reek/issues{/number}","pulls_url":"https://api.github.com/repos/troessner/reek/pulls{/number}","milestones_url":"https://api.github.com/repos/troessner/reek/milestones{/number}","notifications_url":"https://api.github.com/repos/troessner/reek/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/troessner/reek/labels{/name}","releases_url":"https://api.github.com/repos/troessner/reek/releases{/id}","created_at":"2008-09-05T10:48:33Z","updated_at":"2015-04-07T08:53:55Z","pushed_at":"2015-04-07T18:46:28Z","git_url":"git://github.com/troessner/reek.git","ssh_url":"git@github.com:troessner/reek.git","clone_url":"https://github.com/troessner/reek.git","svn_url":"https://github.com/troessner/reek","homepage":"https://github.com/troessner/reek/wiki","size":7006,"stargazers_count":1236,"watchers_count":1236,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":83,"mirror_url":null,"open_issues_count":21,"forks":83,"open_issues":21,"watchers":1236,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/troessner/reek/pulls/428"},"html":{"href":"https://github.com/troessner/reek/pull/428"},"issue":{"href":"https://api.github.com/repos/troessner/reek/issues/428"},"comments":{"href":"https://api.github.com/repos/troessner/reek/issues/428/comments"},"review_comments":{"href":"https://api.github.com/repos/troessner/reek/pulls/428/comments"},"review_comment":{"href":"https://api.github.com/repos/troessner/reek/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/troessner/reek/pulls/428/commits"},"statuses":{"href":"https://api.github.com/repos/troessner/reek/statuses/e803797dd9e62cc0decaef298a543c41e0275f3c"}}}}