Sha256: 684fe5850a204d98c4fecbe6f6ff70804bc6ac2d7ec3abb8ee3cd09a885829bc

Contents?: true

Size: 740 Bytes

Versions: 6

Compression:

Stored size: 740 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_hint}.",
            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.to_regexp}.*/)
      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_tracker_shorthand.rb
git-lint-6.2.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-6.1.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-6.0.2 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-6.0.1 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
git-lint-6.0.0 lib/git/lint/analyzers/commit_body_tracker_shorthand.rb