Sha256: 2dcd9343b8c74825e7dd1e5d3517d08c0905f976f9da9d9d1d27d4231dd16fcf

Contents?: true

Size: 892 Bytes

Versions: 11

Compression:

Stored size: 892 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitBodyBullet < Abstract
        def self.defaults
          {
            enabled: true,
            severity: :error,
            excludes: %w[\\* •]
          }
        end

        def valid?
          commit.body_lines.all? { |line| !invalid_line? line }
        end

        def issue
          return {} if valid?

          {
            hint: %(Avoid: #{filter_list.to_hint}.),
            lines: affected_commit_body_lines
          }
        end

        protected

        def load_filter_list
          Kit::FilterList.new settings.fetch :excludes
        end

        # :reek:FeatureEnvy
        def invalid_line? line
          return false if line.strip.empty?

          !line.match?(/\A(?!\s*#{Regexp.union filter_list.to_regexp}\s+).+\Z/)
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
git-lint-2.2.1 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-2.2.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-2.1.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-2.0.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-1.4.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-1.3.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-1.2.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-1.1.1 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-1.1.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-1.0.1 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-1.0.0 lib/git/lint/analyzers/commit_body_bullet.rb