Sha256: 301526a1a3a82e93c9ebfcab2aee5fa9a77c26943941a097807ec2bd7c488963

Contents?: true

Size: 878 Bytes

Versions: 8

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      class CommitBodyBulletDelimiter < Abstract
        def self.defaults
          {
            enabled: true,
            severity: :error,
            includes: %w[\\-]
          }
        end

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

        def issue
          return {} if valid?

          {
            hint: "Use space after bullet.",
            lines: affected_commit_body_lines
          }
        end

        protected

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

        def invalid_line? line
          line.match?(/\A\s*#{pattern}(?!(#{pattern}|\s)).+\Z/)
        end

        def pattern
          Regexp.union filter_list.to_regexp
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git-lint-2.2.1 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb
git-lint-2.2.0 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb
git-lint-2.1.0 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb
git-lint-2.0.0 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb
git-lint-1.4.0 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb
git-lint-1.3.0 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb
git-lint-1.2.0 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb
git-lint-1.1.1 lib/git/lint/analyzers/commit_body_bullet_delimiter.rb