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

properly fix group of annotation keywords (for example "TODO HACK lorem ipsum") [will be wontfixed by bot] #6630

Closed
matkoniecz opened this issue Jan 7, 2019 · 6 comments · Fixed by #10039

Comments

@matkoniecz
Copy link

matkoniecz commented Jan 7, 2019

In comments like TODO HACK lorem ipsum Style/CommentAnnotation should not add colon after the first keyword if multiple are present - but rather after entire keyword group.


Expected behavior

# TODO HACK lorem ipsum is changed into # TODO HACK: lorem ipsum

Actual behavior

# TODO HACK lorem ipsum is changed into # TODO: HACK lorem ipsum

Steps to reproduce the problem

run rubocop --auto-correct on

# frozen_string_literal: true

# TODO HACK why some horrible problem should be fixed
def dummy_function
  puts "rubocop: #{`rubocop --version`}"
  puts "ruby: #{`ruby --version`}"
end

dummy_function

See https://github.com/matkoniecz/reproducible_rubocop_bug for test case with https://github.com/matkoniecz/reproducible_rubocop_bug/commit/0a21f4f7b40ff9f97e1b9ae106017b76ec189a21 as bugged Rubocop edit

From 0a21f4f7b40ff9f97e1b9ae106017b76ec189a21 Mon Sep 17 00:00:00 2001
From: Mateusz Konieczny <matkoniecz@gmail.com>
Date: Mon, 7 Jan 2019 11:23:43 +0100
Subject: [PATCH] after rubocop --auto-correct

---
 examples.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples.rb b/examples.rb
index 1544891..380c606 100644
--- a/examples.rb
+++ b/examples.rb
@@ -1,6 +1,6 @@
 # frozen_string_literal: true
 
-# TODO HACK why some horrible problem should be fixed
+# TODO: HACK why some horrible problem should be fixed
 def dummy_function
   puts "rubocop: #{`rubocop --version`}"
   puts "ruby: #{`ruby --version`}"

RuboCop version

rubocop -V
0.62.0 (using Parser 2.5.1.2, running on ruby 2.4.5 x86_64-linux-gnu)
matkoniecz added a commit to matkoniecz/matkoniecz-ruby-style that referenced this issue Jan 7, 2019
@tejasbubane
Copy link
Contributor

tejasbubane commented Jan 14, 2019

@matkoniecz For this to work in current rubocop version, you will have to add your keyword TODO HACK to the Keywords section of this cop config. These are the defaults which the cop looks out for: https://github.com/rubocop-hq/rubocop/blob/master/config/default.yml#L2960-L2965

@matkoniecz
Copy link
Author

I tried

Style/CommentAnnotation:
  Description: >-
                 Checks formatting of special comments
                 (TODO, FIXME, OPTIMIZE, HACK, REVIEW).
  StyleGuide: '#annotate-keywords'
  Enabled: true
  Keywords:
    - TODO HACK
    - TODO
    - FIXME
    - OPTIMIZE
    - HACK
    - REVIEW

in my config file. I still got

# TODO: HACK why some horrible problem should be fixed

@stale
Copy link

stale bot commented Jul 22, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added stale Issues that haven't been active in a while and removed stale Issues that haven't been active in a while labels Jul 22, 2019
@stale
Copy link

stale bot commented May 23, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added stale Issues that haven't been active in a while and removed stale Issues that haven't been active in a while labels May 23, 2020
@matkoniecz matkoniecz changed the title properly fix group of annotation keywords (for example "TODO HACK lorem ipsum") properly fix group of annotation keywords (for example "TODO HACK lorem ipsum") [will be wontfixed by bot] May 23, 2020
@stale
Copy link

stale bot commented Nov 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

@stale stale bot added the stale Issues that haven't been active in a while label Nov 21, 2020
@dvandersluis
Copy link
Member

Sorry for the long delay in fixing this, I've opened #10039.

dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Aug 24, 2021
bbatsov pushed a commit that referenced this issue Aug 25, 2021
@dvandersluis dvandersluis removed the stale Issues that haven't been active in a while label Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants