Sha256: a6ff4aaf20e3ac02a20a11e985da3c572023d3145b3dd98f4b23b339e7d953f7

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

require "reek/cli/application"

module RepoAnalyzer
  class ReekExtractor < ProjectInfoExtractor
    private

    def extracted_info
      { warnings: reek_info }
    end

    def reek_info
      @reek_info ||= reek_json.inject({}) do |memo, warning|
        memo[warning["smell_type"]] ||= []
        memo[warning["smell_type"]] << {
          lines: warning["lines"],
          message: warning["message"],
          source: relative_file_name(warning["source"]),
          name: warning["name"],
          documentation_link: warning["documentation_link"]
        }
        memo
      end
    end

    def relative_file_name(file_path)
      file_path.gsub(%r{\A\D*#{project_data_bridge.project_path}/}, "")
    end

    def reek_json
      application = Reek::CLI::Application.new(
        ["--format=json", project_data_bridge.project_path]
      )

      result = OutputUtils.with_captured_stdout { application.execute }
      JSON.parse(result)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
repo_analyzer-1.6.0 app/extractors/repo_analyzer/reek_extractor.rb
repo_analyzer-1.5.0 app/extractors/repo_analyzer/reek_extractor.rb
repo_analyzer-1.4.0 app/extractors/repo_analyzer/reek_extractor.rb