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

standardrb --generate-todo replaces any existing todo file with deltas only #565

Closed
knutsenm opened this issue May 30, 2023 · 3 comments · Fixed by #587
Closed

standardrb --generate-todo replaces any existing todo file with deltas only #565

knutsenm opened this issue May 30, 2023 · 3 comments · Fixed by #587
Labels
standard bug 🐞 A bug in Standard

Comments

@knutsenm
Copy link

@mrbiggred FYI,

I was introducing standard-rails to the project I'm trying to convert from plain rubocop (because @searls fixed standardrb/standard-rails/issues/7, tyvm), but when I ran standardrb --generate-todo it replaced the existing todo file with one that only contained ignores for the Rails cops, losing the previous ignores.

The fix was to remove .standard_todo.yml first, but I wonder if that should be documented or if it can be automated.

@searls searls added the standard bug 🐞 A bug in Standard label May 31, 2023
@searls
Copy link
Contributor

searls commented May 31, 2023

Definitely sounds like a boog.

Strong suspect it has something to do with using the config in its runner and then dumping out the resulting error file as a todo in genrunner.rb.

# Run Rubocop to generate the files with errors into the temp file.
config.rubocop_options[:formatters] = [["json", temp_file.path]]
config.rubocop_options[:out] = temp_file.path
exit_code = Runners::Rubocop.new.call(config)

That config will have been configured normally, including with all the ignores of the todo yaml file, meaning those won't be present so they'll be excluded in the newly generated file.

@mrbiggred
Copy link
Contributor

@knutsenm thanks for bringing up the issue and finding a workaround of removing the existing the .standard_todo.yml file before regenerating the new todo file. That will help other people who encounter this issue.

My initial guess as to the root cause is the same as @searls:

That config will have been configured normally, including with all the ignores of the todo yaml file, meaning those won't be present so they'll be excluded in the newly generated file.

I won't have time to investigate this issue till later this week but right off the top of my head a possible fix for the --generate-todo process to delete the .standard_todo.yml.

Let me know if you there is anything else that would make adding Standard to an existing project easier.

@knutsenm
Copy link
Author

I was going to suggest the internal equivalent of standardrb --todo /dev/null, but then I noticed that

  • that option, and --config, have both been dropped from the README (although they're still in the code), and
  • when I try it, I get an error: it's being passed through to rubocop, which doesn't recognize it; a separate bug?

The --config option does seem to work, perhaps because Standard::MergesSettings#without_banned strips it. Maybe it ought to do the same for --yaml? Or perhaps ResolvesYamlOption ought to strip what it finds from argv; I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standard bug 🐞 A bug in Standard
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants