Sha256: 24b14ee8eec8dff33621cee19f68187685b612d81861b6c8be398824c92c235a

Contents?: true

Size: 1005 Bytes

Versions: 8

Compression:

Stored size: 1005 Bytes

Contents

#!/usr/bin/env ruby
require 'json'

#
# ruby-author-warnings
#
# This script outputs the authors of the lines of code that
# have been flagged by Rubocop as having too high of a complexity.
#
# Three metrics are used to determine complexity:
#
# - ABC Size
# - Cyclomatic Complexity
# - Perceived Complexity
#
# Each line of code can trigger one or more of these metrics.
# Each triggered line is listed as a separate warning.
#

RUBOCOP_WARNINGS = `rubocop --format json --force-default-config --only Metrics/AbcSize,Metrics/BlockLength,Metrics/BlockNesting,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity`

LOCATIONS =
  JSON
  .parse(RUBOCOP_WARNINGS)['files']
  .reject { |f| f['offenses'].empty? }
  .map do |f|
    f['offenses']
      .map { |o| { path: f['path'], begin: o['location']['start_line'], end: o['location']['last_line'] } }
  end
    .flatten

LOCATIONS.each do |location|
  puts `line-authors #{location[:path]} #{location[:begin]} #{location[:end]}`
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
quality_report-1.7.0 exe/ruby-author-warnings
quality_report-1.6.0 exe/ruby-author-warnings
quality_report-1.5.0 exe/ruby-author-warnings
quality_report-1.4.0 exe/ruby-author-warnings
quality_report-1.3.0 exe/ruby-author-warnings
quality_report-1.2.2 exe/ruby-author-warnings
quality_report-1.2.1 exe/ruby-author-warnings
quality_report-1.2.0 exe/ruby-author-warnings