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

add cop for "global method" #9734

Closed
grosser opened this issue Apr 23, 2021 · 1 comment · Fixed by #9755
Closed

add cop for "global method" #9734

grosser opened this issue Apr 23, 2021 · 1 comment · Fixed by #9755
Labels
feature request good first issue Easy task, suitable for newcomers to the project

Comments

@grosser
Copy link
Contributor

grosser commented Apr 23, 2021

feature request

We have a project were many people contribute that don't know ruby well, they often write methods that are global, I'd like to stop them
this also often happens in things like Rakefile or *.rake files

Describe the solution you'd like

class Foo
  def not_global <- Good
  end
end
def this_is_global <- Bad
end

Describe alternatives you've considered

git grep '^def works, but would be nice if it's in rubocop

@bbatsov bbatsov added feature request good first issue Easy task, suitable for newcomers to the project labels Apr 24, 2021
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 24, 2021

The idea makes sense to me, although such a cop should likely be disabled by default as for many scripts top-level method definition are perfectly fine.

tejasbubane added a commit to tejasbubane/rubocop that referenced this issue May 5, 2021
bbatsov pushed a commit that referenced this issue May 7, 2021
kachick added a commit to kachick/rspec-matchers-power_assert_matchers that referenced this issue May 23, 2021
kachick added a commit to kachick/ruby-ulid that referenced this issue May 23, 2021
kachick added a commit to kachick/irb-power_assert that referenced this issue May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request good first issue Easy task, suitable for newcomers to the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants