Class: Codegrade::Grader::Rubocop
- Inherits:
-
Object
- Object
- Codegrade::Grader::Rubocop
- Defined in:
- lib/codegrade/grader/rubocop.rb
Instance Attribute Summary collapse
-
#config_store ⇒ Object
readonly
Returns the value of attribute config_store.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
- #grade ⇒ Object
-
#initialize(file) ⇒ Rubocop
constructor
A new instance of Rubocop.
Constructor Details
#initialize(file) ⇒ Rubocop
Returns a new instance of Rubocop.
6 7 8 9 |
# File 'lib/codegrade/grader/rubocop.rb', line 6 def initialize(file) @config_store = RuboCop::ConfigStore.new @file = file end |
Instance Attribute Details
#config_store ⇒ Object (readonly)
Returns the value of attribute config_store.
4 5 6 |
# File 'lib/codegrade/grader/rubocop.rb', line 4 def config_store @config_store end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
4 5 6 |
# File 'lib/codegrade/grader/rubocop.rb', line 4 def file @file end |
Instance Method Details
#grade ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/codegrade/grader/rubocop.rb', line 11 def grade processed_file = RuboCop::ProcessedSource.from_file(file) config = config_store.for(processed_file.path) team = RuboCop::Cop::Team.new(classes, config, {}) team.inspect_file(processed_file).map do |rubocop_offense| Offense.new(category: rubocop_offense., line_number: rubocop_offense.line, column_number: rubocop_offense.real_column, file: file, source: rubocop_offense.location.source) end end |