{"action":"closed","issue":{"url":"https://api.github.com/repos/w0rp/ale/issues/1580","repository_url":"https://api.github.com/repos/w0rp/ale","labels_url":"https://api.github.com/repos/w0rp/ale/issues/1580/labels{/name}","comments_url":"https://api.github.com/repos/w0rp/ale/issues/1580/comments","events_url":"https://api.github.com/repos/w0rp/ale/issues/1580/events","html_url":"https://github.com/w0rp/ale/issues/1580","id":322977200,"node_id":"MDU6SXNzdWUzMjI5NzcyMDA=","number":1580,"title":"Rubocop fixer ignores filename for Exclude statements","user":{"login":"CGamesPlay","id":1216626,"node_id":"MDQ6VXNlcjEyMTY2MjY=","avatar_url":"https://avatars3.githubusercontent.com/u/1216626?v=4","gravatar_id":"","url":"https://api.github.com/users/CGamesPlay","html_url":"https://github.com/CGamesPlay","followers_url":"https://api.github.com/users/CGamesPlay/followers","following_url":"https://api.github.com/users/CGamesPlay/following{/other_user}","gists_url":"https://api.github.com/users/CGamesPlay/gists{/gist_id}","starred_url":"https://api.github.com/users/CGamesPlay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CGamesPlay/subscriptions","organizations_url":"https://api.github.com/users/CGamesPlay/orgs","repos_url":"https://api.github.com/users/CGamesPlay/repos","events_url":"https://api.github.com/users/CGamesPlay/events{/privacy}","received_events_url":"https://api.github.com/users/CGamesPlay/received_events","type":"User","site_admin":false},"labels":[{"id":439268496,"node_id":"MDU6TGFiZWw0MzkyNjg0OTY=","url":"https://api.github.com/repos/w0rp/ale/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2018-05-14T20:53:05Z","updated_at":"2018-10-26T16:16:50Z","closed_at":"2018-10-26T16:16:50Z","author_association":"NONE","body":"Rubocop isn't being provided with the correct filename when running with `--auto-correct`, and so it makes changes in violation of the `Exclude` and `Include` directives in the config file.\r\n\r\n## Information\r\n\r\n**VIM version**\r\n\r\n```\r\nVIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 22 2018 12:40:49)\r\nmacOS version\r\n```\r\n\r\nOperating System: macOS 10.12.6 (16G1314)\r\n\r\n### :ALEInfo\r\n\r\n```\r\n Current Filetype: ruby\r\nAvailable Linters: ['brakeman', 'rails_best_practices', 'reek', 'rubocop', 'ruby']\r\n  Enabled Linters: ['brakeman', 'rails_best_practices', 'reek', 'rubocop', 'ruby']\r\n Linter Variables:\r\n\r\nlet g:ale_ruby_brakeman_options = ''\r\nlet g:ale_ruby_reek_show_context = 0\r\nlet g:ale_ruby_reek_show_wiki_link = 0\r\nlet g:ale_ruby_rubocop_executable = 'rubocop'\r\nlet g:ale_ruby_rubocop_options = ''\r\nlet g:ale_ruby_ruby_executable = 'ruby'\r\n Global Variables:\r\n\r\nlet g:ale_cache_executable_check_failures = 0\r\nlet g:ale_change_sign_column_color = 0\r\nlet g:ale_command_wrapper = ''\r\nlet g:ale_completion_delay = 100\r\nlet g:ale_completion_enabled = 0\r\nlet g:ale_completion_max_suggestions = 50\r\nlet g:ale_echo_cursor = 1\r\nlet g:ale_echo_msg_error_str = 'Error'\r\nlet g:ale_echo_msg_format = '%code: %%s'\r\nlet g:ale_echo_msg_info_str = 'Info'\r\nlet g:ale_echo_msg_warning_str = 'Warning'\r\nlet g:ale_enabled = 1\r\nlet g:ale_fix_on_save = 1\r\nlet g:ale_fixers = {'ruby': ['rubocop']}\r\nlet g:ale_history_enabled = 1\r\nlet g:ale_history_log_output = 1\r\nlet g:ale_keep_list_window_open = 0\r\nlet g:ale_lint_delay = 200\r\nlet g:ale_lint_on_enter = 1\r\nlet g:ale_lint_on_filetype_changed = 1\r\nlet g:ale_lint_on_save = 1\r\nlet g:ale_lint_on_text_changed = 'never'\r\nlet g:ale_lint_on_insert_leave = 0\r\nlet g:ale_linter_aliases = {}\r\nlet g:ale_linters = {}\r\nlet g:ale_linters_explicit = 0\r\nlet g:ale_list_window_size = 10\r\nlet g:ale_list_vertical = 0\r\nlet g:ale_loclist_msg_format = '%code: %%s'\r\nlet g:ale_max_buffer_history_size = 20\r\nlet g:ale_max_signs = -1\r\nlet g:ale_maximum_file_size = 0\r\nlet g:ale_open_list = 1\r\nlet g:ale_pattern_options = {}\r\nlet g:ale_pattern_options_enabled = 0\r\nlet g:ale_set_balloons = 1\r\nlet g:ale_set_highlights = 1\r\nlet g:ale_set_loclist = 1\r\nlet g:ale_set_quickfix = 0\r\nlet g:ale_set_signs = 1\r\nlet g:ale_sign_column_always = 1\r\nlet g:ale_sign_error = '>>'\r\nlet g:ale_sign_info = '--'\r\nlet g:ale_sign_offset = 1000000\r\nlet g:ale_sign_style_error = '>>'\r\nlet g:ale_sign_style_warning = '--'\r\nlet g:ale_sign_warning = '--'\r\nlet g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']\r\nlet g:ale_type_map = {}\r\nlet g:ale_warn_about_trailing_blank_lines = 1\r\nlet g:ale_warn_about_trailing_whitespace = 1\r\n  Command History:\r\n\r\n(finished - exit code 2) ['/bin/sh', '-c', '''rubocop'' --format json --force-exclusion  --stdin ''/Users/rpatterson/Projects/SimplyInsured/lib/plan_batch_importer.rb'' < ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1992/plan_batch_importer.rb''']\r\n\r\n<<<NO OUTPUT RETURNED>>>\r\n\r\n(finished - exit code 0) ['/bin/sh', '-c', '''ruby'' -w -c -T1 ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1993/plan_batch_importer.rb''']\r\n\r\n<<<NO OUTPUT RETURNED>>>\r\n\r\n(finished - exit code 1) ['/bin/sh', '-c', '''rubocop'' --config ''/Users/rpatterson/Projects/SimplyInsured/.rubocop.yml'' --auto-correct ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1994/plan_batch_importer.rb''']\r\n(executable check - failure) brakeman\r\n(executable check - failure) rails_best_practices\r\n(executable check - failure) reek\r\n(finished - exit code 0) ['/bin/sh', '-c', '''rubocop'' --format json --force-exclusion  --stdin ''/Users/rpatterson/Projects/SimplyInsured/lib/plan_batch_importer.rb'' < ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1995/plan_batch_importer.rb''']\r\n\r\n<<<OUTPUT STARTS>>>\r\n{\"metadata\":{\"rubocop_version\":\"0.55.0\",\"ruby_engine\":\"ruby\",\"ruby_version\":\"2.1.5\",\"ruby_patchlevel\":\"273\",\"ruby_platform\":\"x86_64-darwin14.0\"},\"files\":[{\"path\":\"lib/plan_batch_importer.rb\",\"offenses\":[]}],\"summary\":{\"offense_count\":0,\"target_file_count\":1,\"inspected_file_count\":1}}\r\n<<<OUTPUT ENDS>>>\r\n\r\n(finished - exit code 0) ['/bin/sh', '-c', '''ruby'' -w -c -T1 ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1996/plan_batch_importer.rb''']\r\n\r\n<<<NO OUTPUT RETURNED>>>\r\n\r\n(finished - exit code 1) ['/bin/sh', '-c', '''rubocop'' --config ''/Users/rpatterson/Projects/SimplyInsured/.rubocop.yml'' --auto-correct ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1997/plan_batch_importer.rb''']\r\n(executable check - failure) brakeman\r\n(executable check - failure) rails_best_practices\r\n(executable check - failure) reek\r\n(finished - exit code 0) ['/bin/sh', '-c', '''rubocop'' --format json --force-exclusion  --stdin ''/Users/rpatterson/Projects/SimplyInsured/lib/plan_batch_importer.rb'' < ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1998/plan_batch_importer.rb''']\r\n\r\n<<<OUTPUT STARTS>>>\r\n{\"metadata\":{\"rubocop_version\":\"0.55.0\",\"ruby_engine\":\"ruby\",\"ruby_version\":\"2.1.5\",\"ruby_patchlevel\":\"273\",\"ruby_platform\":\"x86_64-darwin14.0\"},\"files\":[{\"path\":\"lib/plan_batch_importer.rb\",\"offenses\":[]}],\"summary\":{\"offense_count\":0,\"target_file_count\":1,\"inspected_file_count\":1}}\r\n<<<OUTPUT ENDS>>>\r\n\r\n(finished - exit code 0) ['/bin/sh', '-c', '''ruby'' -w -c -T1 ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/1999/plan_batch_importer.rb''']\r\n\r\n<<<NO OUTPUT RETURNED>>>\r\n\r\n(finished - exit code 1) ['/bin/sh', '-c', '''rubocop'' --config ''/Users/rpatterson/Projects/SimplyInsured/.rubocop.yml'' --auto-correct ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/2000/plan_batch_importer.rb''']\r\n(executable check - failure) brakeman\r\n(executable check - failure) rails_best_practices\r\n(executable check - failure) reek\r\n(finished - exit code 0) ['/bin/sh', '-c', '''rubocop'' --format json --force-exclusion  --stdin ''/Users/rpatterson/Projects/SimplyInsured/lib/plan_batch_importer.rb'' < ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/2001/plan_batch_importer.rb''']\r\n\r\n<<<OUTPUT STARTS>>>\r\n{\"metadata\":{\"rubocop_version\":\"0.55.0\",\"ruby_engine\":\"ruby\",\"ruby_version\":\"2.1.5\",\"ruby_patchlevel\":\"273\",\"ruby_platform\":\"x86_64-darwin14.0\"},\"files\":[{\"path\":\"lib/plan_batch_importer.rb\",\"offenses\":[]}],\"summary\":{\"offense_count\":0,\"target_file_count\":1,\"inspected_file_count\":1}}\r\n<<<OUTPUT ENDS>>>\r\n\r\n(finished - exit code 0) ['/bin/sh', '-c', '''ruby'' -w -c -T1 ''/var/folders/2r/0y4kz7r53y1bflwy7l87z4n40000gn/T/vbur5tQ/2002/plan_batch_importer.rb''']\r\n\r\n<<<NO OUTPUT RETURNED>>>\r\n```\r\n\r\n## What went wrong\r\n\r\nRubocop was called as `rubocop --config [project]/.rubocop.yml --auto-correct [tmp]/plan_batch_importer.rb`, which circumvented all of the `Include` and `Exclude` definitions.\r\n\r\n## Reproducing the bug\r\n\r\nSteps for repeating the bug:\r\n\r\n```\r\necho \"''\" > test.rb\r\ncat <<EOF > .rubocop.yml\r\nStyle/StringLiterals:\r\n  EnforcedStyle: double_quotes\r\n  Exclude:\r\n    - test.rb\r\nEOF\r\n```\r\n\r\nOpen `test.rb` in vim and run the ALE fixers. It should leave the file as is, but instead changed the contents of the file to `\"\"`.\r\n\r\n## Fixing the bug\r\n\r\nAfter playing with rubocop a bit, you could get away with invoking rubocop as `rubocop --config [project]/.rubocop.yml --auto-correct --stdin [project]/test.rb < [tmp]/test.rb` and rubocop would work correctly, however it would print output in the format of:\r\n\r\n```\r\nInspecting 1 file\r\n.\r\n\r\n1 file inspected, no offenses detected\r\n====================\r\n''\r\n```\r\n\r\nSo you'd have to slice out the part above the line of `====`."}}
{"actor":{"display_login":"w0rp"}}