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)


10
11
12
# File 'lib/codeqa/checkers/rubocop_full.rb', line 10

def self.available?
  rubocop?
end

.check?(sourcefile) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/codeqa/checkers/rubocop_full.rb', line 6

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

Instance Method Details

#checkObject



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

def check
  return unless self.class.rubocop?
  with_existing_file do |filename|
    args = config_args << filename
    success, raw_json = 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
    handle_rubocop_results(raw_json) unless success
  end
end

#hintObject



18
19
20
# File 'lib/codeqa/checkers/rubocop_full.rb', line 18

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

#nameObject



14
15
16
# File 'lib/codeqa/checkers/rubocop_full.rb', line 14

def name
  'rubocop'
end