Sha256: 45748d99420152f8cd1c92e4662f9db57579b32fbea5079377de08f8bd3779b2

Contents?: true

Size: 719 Bytes

Versions: 161

Compression:

Stored size: 719 Bytes

Contents

# Find max_num_violations in lib/danger/comment_generators/github.md.erb.
class FindMaxNumViolations
  # Save ~ 5000 for contents other than violations to avoid exceeded 65536 max comment length limit.
  LIMIT = 60_000

  def initialize(violations)
    @violations = violations
  end

  def call
    total = 0
    num_of_violations_allowed = 0

    violations.each do |violation|
      message_length = violation.message.length + 80 # 80 is ~ the size of html wraps violation message.

      if total + message_length < LIMIT
        total += message_length
        num_of_violations_allowed += 1
      else
        break
      end
    end

    num_of_violations_allowed
  end

  private

  attr_reader :violations
end

Version data entries

161 entries across 161 versions & 2 rubygems

Version Path
danger-9.5.1 lib/danger/helpers/find_max_num_violations.rb
danger-9.5.0 lib/danger/helpers/find_max_num_violations.rb
danger-9.4.3 lib/danger/helpers/find_max_num_violations.rb
danger-9.4.2 lib/danger/helpers/find_max_num_violations.rb
danger-9.4.1 lib/danger/helpers/find_max_num_violations.rb
danger-9.4.0 lib/danger/helpers/find_max_num_violations.rb
danger-9.3.2 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.36 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.35 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.34 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.33 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.32 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.31 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.30 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.29 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.28 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.27 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.26 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.25 lib/danger/helpers/find_max_num_violations.rb
danger-additional-logging-0.0.24 lib/danger/helpers/find_max_num_violations.rb