Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the Ability to Generate a todo File #155

Merged
merged 23 commits into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
66e7e52
WIP: Adding todo file.
mrbiggred Dec 7, 2019
0bcb871
WIP: renamed to gen-ignore.
mrbiggred Dec 10, 2019
dd4db5b
Add test for finding gen-ignore runner.
mrbiggred Dec 10, 2019
9c91ef4
WIP: Test for merging todo is working.
mrbiggred Dec 10, 2019
9dab4dc
Remove commented out test.
mrbiggred Dec 12, 2019
22732b0
Test for Genignore runner.
mrbiggred Dec 14, 2019
facc4b4
Added generating todo file to the ReadMe.
mrbiggred Dec 14, 2019
bc74d1d
Reword using --todo flag in Readme.
mrbiggred Dec 18, 2019
6b62bda
Renamed temp exclude file to "temp_exclude".
mrbiggred Dec 18, 2019
399c014
Removed some commented out code.
mrbiggred Dec 18, 2019
ebe807c
Fixed type in test fixture.
mrbiggred Dec 18, 2019
502e296
Fixed gen ignore test name.
mrbiggred Dec 18, 2019
6197306
Change file exists test assert to be more readable.
mrbiggred Dec 18, 2019
2f7436e
Fixed issue with generating ignore file in Ruby 2.4.1.
mrbiggred Jan 2, 2020
5dba9e2
Fixed Rubocop caching the working directory during tests.
mrbiggred Jan 31, 2020
cf90f27
Fixed typo in Readme.
mrbiggred Feb 6, 2020
75f112c
Refactor the load yaml config.
mrbiggred Feb 6, 2020
d1fa3b6
Changed cli option to --generate-todo.
mrbiggred Feb 6, 2020
f6e56ad
Print Todo warning.
mrbiggred Apr 9, 2020
3f80ba3
Fixed a failing merge settings test.
mrbiggred Apr 10, 2020
d1b9976
Use temp file when generating ignore file.
mrbiggred Apr 14, 2020
241a412
Merge branch 'master' into feature-add-todo-file
searls May 6, 2020
1099958
Fixed issue with Rubocop config settings leaking between tests.
mrbiggred May 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ If you have an existing project but aren't ready to fix all the files yet you ca
generate a todo file:

```bash
$ bundle exec standardrb --gen-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignorant comment for still having not pulled down the code to run it:

Does standard print a warning when it's running in "todo" mode? I'm ok with naming it "todo" only if that's the case. Come to think of it, printing a progress-to-completion whenever a todo ignore was present would be pretty great.

What I want to avoid is anyone using this as a crutch to think that they're "passing" standard when the presence of a file is actually giving them a free pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@searls if I understand the above correctly you would like Standard to notify the user that the todo file is being used. Currently it does not but I like that idea.

Something like:

$ bundle exec standardrb

Todo file found, ignoring the following files:
- file_a.rb
- file_b.rb

Let me know if I misunderstood what you are asking for. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, something like this would be good. I might make it slightly more scary:

WARNING: this project is being migrated to standard gradually via `whatevertodo.yml` and is ignoring these files:

$ bundle exec standardrb --generate-todo
```

This will create a `.standard_todo.yml` that lists all the files that contain errors.
Expand Down Expand Up @@ -155,7 +155,7 @@ cannot be found by ascending the current working directory (i.e. against a
temporary file buffer in your editor), you can specify the config location with
`--config path/to/.standard.yml`.

Similarly, fow the `.standard_todo.yml` file, you can specify `--todo path/to/.standard_todo.yml`.
Similarly, for the `.standard_todo.yml` file, you can specify `--todo path/to/.standard_todo.yml`.

## What you might do if you're REALLY clever

Expand Down
14 changes: 8 additions & 6 deletions lib/standard/loads_yaml_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ def initialize
end

def call(argv, search_path)
yaml_path = @parses_cli_option.call(argv, "--config") ||
FileFinder.new.call(".standard.yml", search_path)
standard_yaml = load_standard_yaml(yaml_path)
standard_yaml_path = determine_yaml_file(argv, search_path, "--config", ".standard.yml")
todo_yaml_path = determine_yaml_file(argv, search_path, "--todo", ".standard_todo.yml")

todo_yaml_path = @parses_cli_option.call(argv, "--todo") ||
FileFinder.new.call(".standard_todo.yml", search_path)
standard_yaml = load_standard_yaml(standard_yaml_path)
todo_yaml = load_standard_yaml(todo_yaml_path)

merge_ignore(standard_yaml, todo_yaml)
construct_config(yaml_path, standard_yaml)
construct_config(standard_yaml_path, standard_yaml)
end

private
Expand All @@ -31,6 +29,10 @@ def merge_ignore(merge_into_yaml, merge_from_yaml)
merge_into_yaml["ignore"] = merge_into_yaml["ignore"] + merge_from_yaml["ignore"]
end

def determine_yaml_file(argv, search_path, option_name, default_file)
@parses_cli_option.call(argv, option_name) || FileFinder.new.call(default_file, search_path)
end

def load_standard_yaml(yaml_path)
if yaml_path
YAML.load_file(yaml_path) || {}
Expand Down
5 changes: 2 additions & 3 deletions lib/standard/merges_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def call(argv, standard_yaml)

def separate_argv(argv)
argv.partition { |flag|
["--gen-ignore", "--fix", "--no-fix", "--version", "-v", "--help", "-h"].include?(flag)
["--generate-todo", "--fix", "--no-fix", "--version", "-v", "--help", "-h"].include?(flag)
}
end

Expand All @@ -41,11 +41,10 @@ def determine_command(argv)
:help
elsif (argv & ["--version", "-v"]).any?
:version
elsif (argv & ["--gen-ignore"]).any?
elsif (argv & ["--generate-todo"]).any?
:genignore
else
:rubocop

end
end

Expand Down
2 changes: 1 addition & 1 deletion test/standard/merges_settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_version_sets_command_to_version
end

def test_gen_ignore_sets_command_to_gen_ignore
assert_equal :genignore, @subject.call(["--gen-ignore"], {}).runner
assert_equal :genignore, @subject.call(["--generate-todo"], {}).runner
end

def test_fix_flag_sets_auto_correct_options
Expand Down