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

Empty Comment #4274

Closed
matrinox opened this issue Apr 13, 2017 · 3 comments
Closed

Empty Comment #4274

matrinox opened this issue Apr 13, 2017 · 3 comments

Comments

@matrinox
Copy link

$ rubocop -V
0.48.1 (using Parser 2.4.0.0, running on ruby 2.3.1 x86_64-darwin16)

This is a feature suggestion for detecting empty comments

1 class User
2   #
3   def initialize
4     ...
5   end
6 end

Line 2 sticks out like a sore thumb. I know some people who do it just to add an extra line after a class, a way to circumvent one of the rubocop rules: Style/EmptyLinesAroundBody. I know the abuse case of this is just to add a dot or something but at least that can be argued as a useless comment

@bbatsov
Copy link
Collaborator

bbatsov commented Apr 15, 2017

Yeah, it'd be nice to deal with those.

@matrinox
Copy link
Author

@bbatsov glad you feel the same way :)

@tejasbubane
Copy link
Contributor

I am working on this.

tejasbubane added a commit to tejasbubane/rubocop that referenced this issue Apr 19, 2017
Along with auto-correction.

Closes rubocop#4274.
koic added a commit to koic/rubocop that referenced this issue Jan 21, 2018
Fixes rubocop#4274. And reatake rubocop#4288.

## Feature

This cop checks empty comment.

First of all, this cop only offense a single `#` without a comment text,
which is an obvious empty comment.

### Bad case

```ruby
#
class Foo
end
```

### Good case

```ruby
#
# Description of `Foo` class.
#
class Foo
end
```

## Other Information

This PR is the first implementation.

This implementation always allows:

### Allow leading and trailing blank lines

This supported the discussion of the following links.

```ruby
#
# Does something cool
#
def something cool
  puts ":+1:"
end
```

rubocop#4288 (comment)

[IMO] This format is preferable.

### Allow border comment

In this initial implementation, the following border comment is allowed.
The reason is that the social impact is unclear. And there are a test
codes that depends on border comment.

```ruby
def foo
end

#################

def bar
end
```

[IMO] I don't think it is good, so it isn't clearly documented as a
good case.

In this way the initial implementation is lightweight. It is good to
change these so that we can switched by configuration later.
bbatsov pushed a commit that referenced this issue Jan 21, 2018
Fixes #4274. And reatake #4288.

## Feature

This cop checks empty comment.

First of all, this cop only offense a single `#` without a comment text,
which is an obvious empty comment.

### Bad case

```ruby
#
class Foo
end
```

### Good case

```ruby
#
# Description of `Foo` class.
#
class Foo
end
```

## Other Information

This PR is the first implementation.

This implementation always allows:

### Allow leading and trailing blank lines

This supported the discussion of the following links.

```ruby
#
# Does something cool
#
def something cool
  puts ":+1:"
end
```

#4288 (comment)

[IMO] This format is preferable.

### Allow border comment

In this initial implementation, the following border comment is allowed.
The reason is that the social impact is unclear. And there are a test
codes that depends on border comment.

```ruby
def foo
end

#################

def bar
end
```

[IMO] I don't think it is good, so it isn't clearly documented as a
good case.

In this way the initial implementation is lightweight. It is good to
change these so that we can switched by configuration later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants