Sha256: a61683a7dbb74c4be32e4592dcaa7b2b9f3cb63b943e371c36a70e6de989a21f

Contents?: true

Size: 798 Bytes

Versions: 6

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes commit body for correct bullet point syntax.
      class CommitBodyBullet < Abstract
        def valid? = commit.body_lines.all? { |line| !invalid_line? line }

        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 configuration.commits_body_bullet_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

6 entries across 6 versions & 1 rubygems

Version Path
git-lint-6.2.1 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-6.2.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-6.1.0 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-6.0.2 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-6.0.1 lib/git/lint/analyzers/commit_body_bullet.rb
git-lint-6.0.0 lib/git/lint/analyzers/commit_body_bullet.rb