Skip to content

Performance Count Cop does not work #69

@enthusiasmus

Description

@enthusiasmus

Expected behavior

I am expecting offenses for

        [1, 2, 3].select { |e| e > 2 }.size
        [1, 2, 3].reject { |e| e > 2 }.size
        [1, 2, 3].select { |e| e > 2 }.length
        [1, 2, 3].reject { |e| e > 2 }.length

as seen in https://github.com/rubocop-hq/rubocop-performance/blob/master/lib/rubocop/cop/performance/count.rb

Actual behavior

I don't receive offenses

Steps to reproduce the problem

file foobar.rb with

# frozen_string_literal: true

def foobar
  [1, 2, 3].select { |e| e > 2 }.size
  [1, 2, 3].reject { |e| e > 2 }.size
  [1, 2, 3].select { |e| e > 2 }.length
  [1, 2, 3].reject { |e| e > 2 }.length
end

executing rubocop performance via rubocop --require rubocop-performance foobar.rb

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

$ [bundle exec] rubocop -V
0.72.0 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-linux)

rubocop-performance version: 1.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions