Sha256: 6efe1b539a505877cf53a47031b0e958e042bf946957f7c66c4bb7a264cb471a

Contents?: true

Size: 1.33 KB

Versions: 15

Compression:

Stored size: 1.33 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

      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

15 entries across 15 versions & 1 rubygems

Version Path
ndr_dev_support-5.1.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.0.1 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-5.0.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-4.2.1 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-4.2.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-4.1.3 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-4.1.2 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-4.1.1 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-4.1.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-4.0.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-3.1.3 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-3.1.2 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-3.1.1 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-3.1.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb
ndr_dev_support-3.0.0 lib/ndr_dev_support/rake_ci/brakeman_helper.rb