Class: Codeqa::Checkers::Rubocop

Inherits:
Codeqa::Checker show all
Defined in:
lib/codeqa/checkers/rubocop_full.rb

Direct Known Subclasses

RubocopFormatter, RubocopLint

Instance Attribute Summary

Attributes inherited from Codeqa::Checker

#errors, #sourcefile

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Codeqa::Checker

#initialize

Constructor Details

This class inherits a constructor from Codeqa::Checker

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/codeqa/checkers/rubocop_full.rb', line 8

def self.available?
  rubocop?
end

.check?(sourcefile) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/codeqa/checkers/rubocop_full.rb', line 4

def self.check?(sourcefile)
  sourcefile.ruby?
end

Instance Method Details

#checkObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/codeqa/checkers/rubocop_full.rb', line 20

def check
  return unless self.class.rubocop?
  with_existing_file do |filename|
    args = config_args << filename
    success, captured = capture do
      if defined?(RuboCop) # its RuboCop since 0.24
        ::RuboCop::CLI.new.run(default_args + args) == 0
      else
        ::Rubocop::CLI.new.run(default_args + args) == 0
      end
    end
    errors.add(nil, captured) unless success
  end
end

#hintObject



16
17
18
# File 'lib/codeqa/checkers/rubocop_full.rb', line 16

def hint
  'Rubocop does not like your syntax, please fix your code.'
end

#nameObject



12
13
14
# File 'lib/codeqa/checkers/rubocop_full.rb', line 12

def name
  'rubocop'
end