Class: StudFinder::Complexity
- Inherits:
-
Object
- Object
- StudFinder::Complexity
- Defined in:
- lib/stud_finder/complexity.rb
Defined Under Namespace
Constant Summary collapse
- COMPLEXITY_COP =
'Metrics/CyclomaticComplexity'- COMPLEXITY_PATTERN =
%r{\[(\d+)/0\]}- PARSE_ERROR_COPS =
%w[Lint/Syntax].freeze
- RUBOCOP_CONFIG =
<<~YAML AllCops: DisabledByDefault: true Metrics/CyclomaticComplexity: Enabled: true Max: 0 YAML
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(repo_path:, files:, stderr: $stderr) ⇒ Complexity
constructor
A new instance of Complexity.
Constructor Details
#initialize(repo_path:, files:, stderr: $stderr) ⇒ Complexity
Returns a new instance of Complexity.
24 25 26 27 28 |
# File 'lib/stud_finder/complexity.rb', line 24 def initialize(repo_path:, files:, stderr: $stderr) @repo_path = File.(repo_path) @files = files @stderr = stderr end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/stud_finder/complexity.rb', line 30 def call stdout, stderr, status = run_rubocop raise Error, (stderr) if status.exitstatus == 2 raise Error, (stderr) unless [0, 1].include?(status.exitstatus) parse(stdout) rescue Errno::ENOENT raise Error, 'Error: rubocop not found. Install it: gem install rubocop' rescue JSON::ParserError => e raise Error, "Error: failed to parse RuboCop JSON output: #{e.}" end |