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

One line methods counted incorrectly #66

Open
prpetten opened this issue Sep 18, 2016 · 1 comment
Open

One line methods counted incorrectly #66

prpetten opened this issue Sep 18, 2016 · 1 comment

Comments

@prpetten
Copy link

The following code:

# spec/controllers/concerns/concern_name_spec.rb 
describe ConcernName, type: :controller do
  controller(ApplicationController) do
    include ConcernName

    before_action :assign_resource, only: [:update, :destroy]

    def create; end

    def update; end

    def destroy; end

    def assign_resource
      @object = ModelName.find(params[:id])
    end
  end

causes

$ sandi_meter -g

Methods with 5+ lines
  Class name       | Method name  | Size  | Path                                                                      
                   | create       | 7     | ./spec/controllers/concerns/concern_name_spec.rb 

However, if I update this to have end on a separate line as shown below, the error magically goes away.

# spec/controllers/concerns/concern_name_spec.rb 
describe ConcernName, type: :controller do
  controller(ApplicationController) do
    include ConcernName

    before_action :assign_resource, only: [:update, :destroy]

    def create
    end

    def update
    end

    def destroy
    end

    def assign_resource
      @object = ModelName.find(params[:id])
    end
  end
@sadir
Copy link

sadir commented Dec 29, 2016

+1. In fact rubocop prefers to change empty methods to the one-line option in your 'before' example. So only one of this linting tool and rubocop can be passing at any one time unless you turn the rule off in rubocop.

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

Successfully merging a pull request may close this issue.

2 participants