git-lint 2.3.3 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/LICENSE.adoc +207 -155
  4. data/README.adoc +203 -222
  5. data/{bin → exe}/git-lint +1 -3
  6. data/lib/git/lint/analyzer.rb +76 -0
  7. data/lib/git/lint/analyzers/abstract.rb +8 -18
  8. data/lib/git/lint/analyzers/commit_author_capitalization.rb +3 -9
  9. data/lib/git/lint/analyzers/commit_author_email.rb +3 -9
  10. data/lib/git/lint/analyzers/commit_author_name.rb +5 -14
  11. data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -9
  12. data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +2 -9
  13. data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +2 -9
  14. data/lib/git/lint/analyzers/commit_body_leading_line.rb +1 -7
  15. data/lib/git/lint/analyzers/commit_body_line_length.rb +4 -11
  16. data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +1 -7
  17. data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -38
  18. data/lib/git/lint/analyzers/commit_body_presence.rb +5 -12
  19. data/lib/git/lint/analyzers/commit_body_single_bullet.rb +2 -9
  20. data/lib/git/lint/analyzers/commit_body_tracker_shorthand.rb +27 -0
  21. data/lib/git/lint/analyzers/commit_subject_length.rb +4 -11
  22. data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -9
  23. data/lib/git/lint/analyzers/commit_subject_suffix.rb +2 -13
  24. data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +3 -12
  25. data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +3 -11
  26. data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +3 -12
  27. data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +4 -13
  28. data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +5 -15
  29. data/lib/git/lint/cli/actions/analyze/branch.rb +43 -0
  30. data/lib/git/lint/cli/actions/analyze/commit.rb +44 -0
  31. data/lib/git/lint/cli/actions/config.rb +37 -0
  32. data/lib/git/lint/cli/actions/hook.rb +34 -0
  33. data/lib/git/lint/cli/parser.rb +33 -0
  34. data/lib/git/lint/cli/parsers/analyze.rb +40 -0
  35. data/lib/git/lint/cli/parsers/core.rb +72 -0
  36. data/lib/git/lint/cli/shell.rb +56 -0
  37. data/lib/git/lint/collector.rb +3 -4
  38. data/lib/git/lint/commits/container.rb +19 -0
  39. data/lib/git/lint/commits/loader.rb +51 -0
  40. data/lib/git/lint/commits/systems/circle_ci.rb +26 -0
  41. data/lib/git/lint/{branches/environments → commits/systems}/git_hub_action.rb +10 -8
  42. data/lib/git/lint/commits/systems/local.rb +26 -0
  43. data/lib/git/lint/{branches/environments → commits/systems}/netlify_ci.rb +14 -10
  44. data/lib/git/lint/configuration/content.rb +26 -0
  45. data/lib/git/lint/configuration/defaults.yml +118 -0
  46. data/lib/git/lint/configuration/loader.rb +50 -0
  47. data/lib/git/lint/configuration/setting.rb +24 -0
  48. data/lib/git/lint/container.rb +41 -0
  49. data/lib/git/lint/errors/severity.rb +1 -0
  50. data/lib/git/lint/errors/sha.rb +1 -0
  51. data/lib/git/lint/identity.rb +2 -1
  52. data/lib/git/lint/kit/filter_list.rb +1 -1
  53. data/lib/git/lint/parsers/trailers/collaborator.rb +1 -0
  54. data/lib/git/lint/rake/tasks.rb +5 -4
  55. data/lib/git/lint/reporters/branch.rb +12 -6
  56. data/lib/git/lint/reporters/commit.rb +3 -1
  57. data/lib/git/lint/reporters/line.rb +3 -5
  58. data/lib/git/lint/reporters/lines/paragraph.rb +3 -0
  59. data/lib/git/lint/reporters/lines/sentence.rb +3 -0
  60. data/lib/git/lint/reporters/style.rb +3 -1
  61. data/lib/git/lint/validators/capitalization.rb +1 -0
  62. data/lib/git/lint/validators/email.rb +1 -0
  63. data/lib/git/lint/validators/name.rb +1 -0
  64. data/lib/git/lint.rb +18 -47
  65. data.tar.gz.sig +0 -0
  66. metadata +55 -29
  67. metadata.gz.sig +0 -0
  68. data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +0 -39
  69. data/lib/git/lint/branches/environments/circle_ci.rb +0 -24
  70. data/lib/git/lint/branches/environments/local.rb +0 -24
  71. data/lib/git/lint/branches/environments/travis_ci.rb +0 -49
  72. data/lib/git/lint/branches/feature.rb +0 -42
  73. data/lib/git/lint/cli.rb +0 -117
  74. data/lib/git/lint/refinements/strings.rb +0 -21
  75. data/lib/git/lint/runner.rb +0 -35
@@ -12,36 +12,24 @@ module Git
12
12
  LEVELS = %i[warn error].freeze
13
13
  ISSUE_LINE_OFFSET = 2
14
14
 
15
- def self.inherited klass
16
- super
17
- @descendants ||= []
18
- @descendants << klass unless klass.to_s.start_with? "#<Class" # Ignore anonymous classes.
19
- end
20
-
21
15
  def self.id = to_s.delete_prefix("Git::Lint::Analyzers").snakecase.to_sym
22
16
 
23
17
  def self.label = to_s.delete_prefix("Git::Lint::Analyzers").titleize
24
18
 
25
- def self.defaults
26
- fail NotImplementedError, "The `.#{__method__}` method must be implemented."
27
- end
28
-
29
- def self.descendants = @descendants || []
30
-
31
19
  def self.build_issue_line(index, line) = {number: index + ISSUE_LINE_OFFSET, content: line}
32
20
 
33
21
  attr_reader :commit
34
22
 
35
- def initialize commit:, settings: self.class.defaults
23
+ def initialize commit, container: Container
36
24
  @commit = commit
37
- @settings = settings
25
+ @container = container
38
26
  @filter_list = load_filter_list
39
27
  end
40
28
 
41
- def enabled? = settings.fetch(:enabled)
29
+ def enabled? = settings.enabled
42
30
 
43
31
  def severity
44
- settings.fetch(:severity).tap do |level|
32
+ settings.severity.tap do |level|
45
33
  fail Errors::Severity, level unless LEVELS.include? level
46
34
  end
47
35
  end
@@ -62,9 +50,9 @@ module Git
62
50
 
63
51
  protected
64
52
 
65
- attr_reader :settings, :filter_list
53
+ attr_reader :container, :filter_list
66
54
 
67
- def load_filter_list = Kit::FilterList.new(settings[:list])
55
+ def load_filter_list = []
68
56
 
69
57
  def affected_commit_body_lines
70
58
  commit.body_lines.each.with_object([]).with_index do |(line, lines), index|
@@ -85,6 +73,8 @@ module Git
85
73
  def invalid_line? _line
86
74
  fail NotImplementedError, "The `.#{__method__}` method must be implemented."
87
75
  end
76
+
77
+ def settings = container[:configuration].find_setting(self.class.id)
88
78
  end
89
79
  end
90
80
  end
@@ -3,16 +3,10 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes author for proper capitalization of author name.
6
7
  class CommitAuthorCapitalization < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error
11
- }
12
- end
13
-
14
- def initialize commit:, settings: self.class.defaults, validator: Validators::Capitalization
15
- super commit: commit, settings: settings
8
+ def initialize commit, validator: Validators::Capitalization
9
+ super commit
16
10
  @validator = validator
17
11
  end
18
12
 
@@ -3,16 +3,10 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes author email address for proper format.
6
7
  class CommitAuthorEmail < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error
11
- }
12
- end
13
-
14
- def initialize commit:, settings: self.class.defaults, validator: Validators::Email
15
- super commit: commit, settings: settings
8
+ def initialize commit, validator: Validators::Email
9
+ super commit
16
10
  @validator = validator
17
11
  end
18
12
 
@@ -3,21 +3,14 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes author name for minimum parts of name.
6
7
  class CommitAuthorName < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- minimum: 2
12
- }
13
- end
14
-
15
- def initialize commit:, settings: self.class.defaults, validator: Validators::Name
16
- super commit: commit, settings: settings
8
+ def initialize commit, validator: Validators::Name
9
+ super commit
17
10
  @validator = validator
18
11
  end
19
12
 
20
- def valid? = validator.new(commit.author_name, minimum: minimum).valid?
13
+ def valid? = validator.new(commit.author_name, minimum:).valid?
21
14
 
22
15
  def issue
23
16
  return {} if valid?
@@ -29,9 +22,7 @@ module Git
29
22
 
30
23
  attr_reader :validator
31
24
 
32
- def minimum
33
- settings.fetch __method__
34
- end
25
+ def minimum = settings.minimum
35
26
  end
36
27
  end
37
28
  end
@@ -3,15 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit body for correct bullet point syntax.
6
7
  class CommitBodyBullet < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- excludes: %w[\\* •]
12
- }
13
- end
14
-
15
8
  def valid? = commit.body_lines.all? { |line| !invalid_line? line }
16
9
 
17
10
  def issue
@@ -25,7 +18,7 @@ module Git
25
18
 
26
19
  protected
27
20
 
28
- def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
21
+ def load_filter_list = Kit::FilterList.new(settings.excludes)
29
22
 
30
23
  # :reek:FeatureEnvy
31
24
  def invalid_line? line
@@ -3,15 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit body for proper capitalization of bullet sentences.
6
7
  class CommitBodyBulletCapitalization < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- includes: %w[\\-]
12
- }
13
- end
14
-
15
8
  def valid? = lowercased_bullets.size.zero?
16
9
 
17
10
  def issue
@@ -25,7 +18,7 @@ module Git
25
18
 
26
19
  protected
27
20
 
28
- def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
21
+ def load_filter_list = Kit::FilterList.new(settings.includes)
29
22
 
30
23
  def invalid_line? line
31
24
  line.match?(/\A\s*#{Regexp.union filter_list.to_regexp}\s[[:lower:]]+/)
@@ -3,15 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit body delimiter usage.
6
7
  class CommitBodyBulletDelimiter < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- includes: %w[\\-]
12
- }
13
- end
14
-
15
8
  def valid? = commit.body_lines.none? { |line| invalid_line? line }
16
9
 
17
10
  def issue
@@ -25,7 +18,7 @@ module Git
25
18
 
26
19
  protected
27
20
 
28
- def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
21
+ def load_filter_list = Kit::FilterList.new(settings.includes)
29
22
 
30
23
  def invalid_line?(line) = line.match?(/\A\s*#{pattern}(?!(#{pattern}|\s)).+\Z/)
31
24
 
@@ -3,14 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes leading line between commit subject and start of body.
6
7
  class CommitBodyLeadingLine < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error
11
- }
12
- end
13
-
14
8
  def valid?
15
9
  message = commit.message
16
10
  subject, body = message.split "\n", 2
@@ -3,33 +3,26 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit body line length to prevent unnecessary horizontal scrolling.
6
7
  class CommitBodyLineLength < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- length: 72
12
- }
13
- end
14
-
15
8
  def valid? = commit.body_lines.all? { |line| !invalid_line? line }
16
9
 
17
10
  def issue
18
11
  return {} if valid?
19
12
 
20
13
  {
21
- hint: "Use #{length} characters or less per line.",
14
+ hint: "Use #{maximum} characters or less per line.",
22
15
  lines: affected_commit_body_lines
23
16
  }
24
17
  end
25
18
 
26
19
  protected
27
20
 
28
- def invalid_line?(line) = line.length > length
21
+ def invalid_line?(line) = line.length > maximum
29
22
 
30
23
  private
31
24
 
32
- def length = settings.fetch(:length)
25
+ def maximum = settings.maximum
33
26
  end
34
27
  end
35
28
  end
@@ -3,14 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes proper capitalization of commit body paragraphs.
6
7
  class CommitBodyParagraphCapitalization < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error
11
- }
12
- end
13
-
14
8
  def self.invalid?(line) = line.match?(/\A[[:lower:]].+\Z/m)
15
9
 
16
10
  def valid? = lowercased_lines.empty?
@@ -3,44 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes use of commit body phrases that are not informative.
6
7
  class CommitBodyPhrase < Abstract
7
- # rubocop:disable Metrics/MethodLength
8
- def self.defaults
9
- {
10
- enabled: true,
11
- severity: :error,
12
- excludes: [
13
- "absolutely",
14
- "actually",
15
- "all intents and purposes",
16
- "along the lines",
17
- "at this moment in time",
18
- "basically",
19
- "each and every one",
20
- "everyone knows",
21
- "fact of the matter",
22
- "furthermore",
23
- "however",
24
- "in due course",
25
- "in the end",
26
- "last but not least",
27
- "matter of fact",
28
- "obviously",
29
- "of course",
30
- "really",
31
- "simply",
32
- "things being equal",
33
- "would like to",
34
- /\beasy\b/,
35
- /\bjust\b/,
36
- /\bquite\b/,
37
- /as\sfar\sas\s.+\sconcerned/,
38
- /of\sthe\s(fact|opinion)\sthat/
39
- ]
40
- }
41
- end
42
- # rubocop:enable Metrics/MethodLength
43
-
44
8
  def valid? = commit.body_lines.all? { |line| !invalid_line? line }
45
9
 
46
10
  def issue
@@ -54,7 +18,7 @@ module Git
54
18
 
55
19
  protected
56
20
 
57
- def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
21
+ def load_filter_list = Kit::FilterList.new(settings.excludes)
58
22
 
59
23
  def invalid_line? line
60
24
  line.downcase.match? Regexp.new(
@@ -3,30 +3,23 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes pretense of commit body.
6
7
  class CommitBodyPresence < Abstract
7
- using GitPlus::Refinements::Strings
8
-
9
- def self.defaults
10
- {
11
- enabled: true,
12
- severity: :warn,
13
- minimum: 1
14
- }
15
- end
8
+ using ::Refinements::Strings
16
9
 
17
10
  def valid?
18
11
  return true if commit.fixup?
19
12
 
20
- valid_lines = commit.body_lines.reject { |line| line.match?(/^\s*$/) }
13
+ valid_lines = commit.body_lines.grep_v(/^\s*$/)
21
14
  valid_lines.size >= minimum
22
15
  end
23
16
 
24
- def minimum = settings.fetch(:minimum)
17
+ def minimum = settings.minimum
25
18
 
26
19
  def issue
27
20
  return {} if valid?
28
21
 
29
- {hint: %(Use minimum of #{"line".pluralize count: minimum} (non-empty).)}
22
+ {hint: %(Use minimum of #{"#{minimum} line".pluralize "s", count: minimum} (non-empty).)}
30
23
  end
31
24
  end
32
25
  end
@@ -3,15 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit bodies with only a single bullet point.
6
7
  class CommitBodySingleBullet < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- includes: %w[\\-]
12
- }
13
- end
14
-
15
8
  def valid? = affected_commit_body_lines.size != 1
16
9
 
17
10
  def issue
@@ -25,7 +18,7 @@ module Git
25
18
 
26
19
  protected
27
20
 
28
- def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
21
+ def load_filter_list = Kit::FilterList.new(settings.includes)
29
22
 
30
23
  def invalid_line?(line) = line.match?(/\A#{Regexp.union filter_list.to_regexp}\s+/)
31
24
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Git
4
+ module Lint
5
+ module Analyzers
6
+ # Analyzes body tracker shorthand usage.
7
+ class CommitBodyTrackerShorthand < Abstract
8
+ def valid? = commit.body_lines.none? { |line| invalid_line? line }
9
+
10
+ def issue
11
+ return {} if valid?
12
+
13
+ {
14
+ hint: "Explain issue instead of using shorthand. Avoid: #{filter_list.to_hint}.",
15
+ lines: affected_commit_body_lines
16
+ }
17
+ end
18
+
19
+ protected
20
+
21
+ def load_filter_list = Kit::FilterList.new(settings.excludes)
22
+
23
+ def invalid_line?(line) = line.match?(/.*#{Regexp.union filter_list.to_regexp}.*/)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,26 +3,19 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit subject length is short and concise.
6
7
  class CommitSubjectLength < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- length: 72
12
- }
13
- end
14
-
15
- def valid? = commit.subject.sub(/(fixup!|squash!)\s{1}/, "").size <= length
8
+ def valid? = commit.subject.sub(/(fixup!|squash!)\s{1}/, "").size <= maximum
16
9
 
17
10
  def issue
18
11
  return {} if valid?
19
12
 
20
- {hint: "Use #{length} characters or less."}
13
+ {hint: "Use #{maximum} characters or less."}
21
14
  end
22
15
 
23
16
  private
24
17
 
25
- def length = settings.fetch(:length)
18
+ def maximum = settings.maximum
26
19
  end
27
20
  end
28
21
  end
@@ -3,15 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit subject uses standard prefix.
6
7
  class CommitSubjectPrefix < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- includes: %w[Fixed Added Updated Removed Refactored]
12
- }
13
- end
14
-
15
8
  def valid?
16
9
  return true if commit.prefix?
17
10
  return true if filter_list.empty?
@@ -27,7 +20,7 @@ module Git
27
20
 
28
21
  protected
29
22
 
30
- def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
23
+ def load_filter_list = Kit::FilterList.new(settings.includes)
31
24
  end
32
25
  end
33
26
  end
@@ -3,19 +3,8 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit subject suffix for punctuation.
6
7
  class CommitSubjectSuffix < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- excludes: [
12
- "\\.",
13
- "\\?",
14
- "\\!"
15
- ]
16
- }
17
- end
18
-
19
8
  def valid?
20
9
  return true if filter_list.empty?
21
10
 
@@ -30,7 +19,7 @@ module Git
30
19
 
31
20
  protected
32
21
 
33
- def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
22
+ def load_filter_list = Kit::FilterList.new(settings.excludes)
34
23
  end
35
24
  end
36
25
  end
@@ -3,24 +3,15 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit trailer collaborator name capitalization.
6
7
  class CommitTrailerCollaboratorCapitalization < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error
11
- }
12
- end
13
-
14
- # rubocop:disable Metrics/ParameterLists
15
- def initialize commit:,
16
- settings: self.class.defaults,
8
+ def initialize commit,
17
9
  parser: Parsers::Trailers::Collaborator,
18
10
  validator: Validators::Capitalization
19
- super commit: commit, settings: settings
11
+ super commit
20
12
  @parser = parser
21
13
  @validator = validator
22
14
  end
23
- # rubocop:enable Metrics/ParameterLists
24
15
 
25
16
  def valid? = affected_commit_trailers.empty?
26
17
 
@@ -3,18 +3,10 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit trailer collaborator duplication.
6
7
  class CommitTrailerCollaboratorDuplication < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error
11
- }
12
- end
13
-
14
- def initialize commit:,
15
- settings: self.class.defaults,
16
- parser: Parsers::Trailers::Collaborator
17
- super commit: commit, settings: settings
8
+ def initialize commit, parser: Parsers::Trailers::Collaborator
9
+ super commit
18
10
  @parser = parser
19
11
  @tally = build_tally
20
12
  end
@@ -3,25 +3,16 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit trailer collaborator email address format.
6
7
  class CommitTrailerCollaboratorEmail < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error
11
- }
12
- end
13
-
14
- # rubocop:disable Metrics/ParameterLists
15
- def initialize commit:,
16
- settings: self.class.defaults,
8
+ def initialize commit,
17
9
  parser: Parsers::Trailers::Collaborator,
18
10
  validator: Validators::Email
19
11
 
20
- super commit: commit, settings: settings
12
+ super commit
21
13
  @parser = parser
22
14
  @validator = validator
23
15
  end
24
- # rubocop:enable Metrics/ParameterLists
25
16
 
26
17
  def valid? = affected_commit_trailers.empty?
27
18
 
@@ -3,19 +3,10 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit trailer collaborator key usage.
6
7
  class CommitTrailerCollaboratorKey < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- includes: ["Co-Authored-By"]
12
- }
13
- end
14
-
15
- def initialize commit:,
16
- settings: self.class.defaults,
17
- parser: Parsers::Trailers::Collaborator
18
- super commit: commit, settings: settings
8
+ def initialize commit, parser: Parsers::Trailers::Collaborator
9
+ super commit
19
10
  @parser = parser
20
11
  end
21
12
 
@@ -32,7 +23,7 @@ module Git
32
23
 
33
24
  protected
34
25
 
35
- def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
26
+ def load_filter_list = Kit::FilterList.new(settings.includes)
36
27
 
37
28
  def invalid_line? line
38
29
  collaborator = parser.new line
@@ -3,26 +3,16 @@
3
3
  module Git
4
4
  module Lint
5
5
  module Analyzers
6
+ # Analyzes commit trailer collaborator name construction.
6
7
  class CommitTrailerCollaboratorName < Abstract
7
- def self.defaults
8
- {
9
- enabled: true,
10
- severity: :error,
11
- minimum: 2
12
- }
13
- end
14
-
15
- # rubocop:disable Metrics/ParameterLists
16
- def initialize commit:,
17
- settings: self.class.defaults,
8
+ def initialize commit,
18
9
  parser: Parsers::Trailers::Collaborator,
19
10
  validator: Validators::Name
20
11
 
21
- super commit: commit, settings: settings
12
+ super commit
22
13
  @parser = parser
23
14
  @validator = validator
24
15
  end
25
- # rubocop:enable Metrics/ParameterLists
26
16
 
27
17
  def valid? = affected_commit_trailers.empty?
28
18
 
@@ -39,14 +29,14 @@ module Git
39
29
 
40
30
  def invalid_line? line
41
31
  collaborator = parser.new line
42
- collaborator.match? && !validator.new(collaborator.name.strip, minimum: minimum).valid?
32
+ collaborator.match? && !validator.new(collaborator.name.strip, minimum:).valid?
43
33
  end
44
34
 
45
35
  private
46
36
 
47
37
  attr_reader :parser, :validator
48
38
 
49
- def minimum = settings.fetch(:minimum)
39
+ def minimum = settings.minimum
50
40
  end
51
41
  end
52
42
  end