-
Notifications
You must be signed in to change notification settings - Fork 203
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
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
66e7e52
WIP: Adding todo file.
mrbiggred 0bcb871
WIP: renamed to gen-ignore.
mrbiggred dd4db5b
Add test for finding gen-ignore runner.
mrbiggred 9c91ef4
WIP: Test for merging todo is working.
mrbiggred 9dab4dc
Remove commented out test.
mrbiggred 22732b0
Test for Genignore runner.
mrbiggred facc4b4
Added generating todo file to the ReadMe.
mrbiggred bc74d1d
Reword using --todo flag in Readme.
mrbiggred 6b62bda
Renamed temp exclude file to "temp_exclude".
mrbiggred 399c014
Removed some commented out code.
mrbiggred ebe807c
Fixed type in test fixture.
mrbiggred 502e296
Fixed gen ignore test name.
mrbiggred 6197306
Change file exists test assert to be more readable.
mrbiggred 2f7436e
Fixed issue with generating ignore file in Ruby 2.4.1.
mrbiggred 5dba9e2
Fixed Rubocop caching the working directory during tests.
mrbiggred cf90f27
Fixed typo in Readme.
mrbiggred 75f112c
Refactor the load yaml config.
mrbiggred d1fa3b6
Changed cli option to --generate-todo.
mrbiggred f6e56ad
Print Todo warning.
mrbiggred 3f80ba3
Fixed a failing merge settings test.
mrbiggred d1b9976
Use temp file when generating ignore file.
mrbiggred 241a412
Merge branch 'master' into feature-add-todo-file
searls 1099958
Fixed issue with Rubocop config settings leaking between tests.
mrbiggred File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require "yaml" | ||
require_relative "rubocop" | ||
|
||
module Standard | ||
module Runners | ||
class Genignore | ||
def call(config) | ||
# Run Rubocop to generate the files with errors. | ||
config.rubocop_options[:formatters] = [["files", "temp_exclude.txt"]] | ||
config.rubocop_options[:format] = "files" | ||
config.rubocop_options[:out] = "temp_exclude.txt" | ||
|
||
File.delete("exclude.txt") if File.exist?("temp_exclude.txt") | ||
Runners::Rubocop.new.call(config) | ||
|
||
# Read in the files with errors. It will have the absolute paths | ||
# of the files but we only want the relative path. | ||
files_with_errors = File.open("temp_exclude.txt").readlines.map(&:chomp) | ||
files_with_errors.map! do |file| | ||
# Get the relative file path. Don't use the | ||
# relative_path_from method as it will raise an | ||
# error in Ruby 2.4.1 and possibly other versions. | ||
# | ||
# https://bugs.ruby-lang.org/issues/10011 | ||
# | ||
file.sub(Dir.pwd + File::SEPARATOR, "") | ||
end | ||
|
||
yaml_format_errors = {"ignore" => files_with_errors} | ||
|
||
# Regenerate the todo file. | ||
File.open(".standard_todo.yml", "w") do |file| | ||
file.puts "# Auto generated files with errors to ignore." | ||
file.puts "# Remove from this list as you refactor files." | ||
file.write(yaml_format_errors.to_yaml) | ||
end | ||
|
||
# Clean up | ||
File.delete("temp_exclude.txt") if File.exist?("temp_exclude.txt") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ignore: | ||
- none_todo_path/**/* | ||
- none_todo_file.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ignore: | ||
- todo_file_one.rb | ||
- todo_file_two.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ErrorsOne | ||
def stuff(id) | ||
if bar = Bar.find(id) | ||
bar.nice! | ||
else | ||
false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
useless_assignment = "LOL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
# Has no errors | ||
class NoErrors | ||
def add(aaaa, bbbb) | ||
aaaa + bbbb | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "test_helper" | ||
|
||
require "standard/runners/genignore" | ||
require "standard/runners/rubocop" | ||
|
||
class Standard::Runners::GenignoreTest < UnitTest | ||
def setup | ||
super | ||
|
||
@subject = Standard::Runners::Genignore.new | ||
end | ||
|
||
def test_todo_generated | ||
FileUtils.rm_rf("tmp/genignore_test") | ||
FileUtils.mkdir_p("tmp/genignore_test") | ||
FileUtils.cp_r("test/fixture/genignore/.", "tmp/genignore_test") | ||
|
||
Dir.chdir("tmp/genignore_test") do | ||
@subject.call(create_config) | ||
end | ||
|
||
assert File.exist?("tmp/genignore_test/.standard_todo.yml") | ||
|
||
expected_yaml = {"ignore" => %w[errors_one.rb errors_two.rb]} | ||
assert_equal expected_yaml, YAML.load_file("tmp/genignore_test/.standard_todo.yml") | ||
end | ||
|
||
private | ||
|
||
def create_config | ||
Standard::Config.new(nil, ["."], {}, RuboCop::ConfigStore.new) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's
exclude.txt
? It's only mentioned here.As for
temp_exclude.txt
, I don't love spitting out a temporary file into a person's project directory, because if there's a failure it'll sit there and they won't know what it is. Maybe it'd be better to use Ruby's tempfile instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated to the code to use Ruby's tempfile. Thanks for the tip.