Sha256: e00c1cdddff3bfbfd33bb9898c08bdd8543988e088ad8b30f3dd43c8b5062d7f

Contents?: true

Size: 731 Bytes

Versions: 5

Compression:

Stored size: 731 Bytes

Contents

# frozen_string_literal: true

module Git
  module Lint
    module Analyzers
      # Analyzes body tracker shorthand usage.
      class CommitBodyTrackerShorthand < Abstract
        def valid? = commit.body_lines.none? { |line| invalid_line? line }

        def issue
          return {} if valid?

          {
            hint: "Explain issue instead of using shorthand. Avoid: #{filter_list.to_usage}.",
            lines: affected_commit_body_lines
          }
        end

        protected

        def load_filter_list
          Kit::FilterList.new configuration.commits_body_tracker_shorthand_excludes
        end

        def invalid_line?(line) = line.match?(/.*#{Regexp.union filter_list}.*/)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
git-lint-7.5.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-7.3.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-7.2.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-7.1.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-7.0.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb