Sha256: 44d243871f8c9a97ba105db798ff0bfabc4580cc7bab4e4b28c0b6011917f62e

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

module NdrDevSupport
  module RakeCI
    # Brakeman helper
    class BrakemanHelper
      require 'set'
      require 'brakeman'
      require_relative 'concerns/commit_metadata_persistable'

      include CommitMetadataPersistable

      attr_reader :new_fingerprints, :old_fingerprints, :tracker

      def run
        @tracker = ::Brakeman.run(app_path: '.')

        last_commit_fingerprints = load_last_commit_data
        if last_commit_fingerprints
          @new_fingerprints = current_fingerprints - last_commit_fingerprints
          @old_fingerprints = last_commit_fingerprints - current_fingerprints
        else
          @new_fingerprints = @old_fingerprints = Set.new
        end
      end

      def warnings
        @tracker.warnings
      end

      def warning_counts_by_confidence
        return @warning_counts_by_confidence if @warning_counts_by_confidence

        @warning_counts_by_confidence = {}
        warnings.group_by(&:confidence).each do |confidence, grouped_warnings|
          @warning_counts_by_confidence[confidence] = grouped_warnings.count
        end
        @warning_counts_by_confidence
      end

      def current_fingerprints
        @current_fingerprints ||= warnings.map(&:fingerprint).to_set
      end

      def save_current_fingerprints
        save_current_commit_data(current_fingerprints)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ndr_dev_support-5.6.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.5.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.8 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.7 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.6 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.5 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.4 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.3 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.2 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.1 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.4.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.3.1 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.3.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.2.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb