git-lint 6.2.0 → 7.0.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.adoc +234 -104
- data/git-lint.gemspec +12 -12
- data/lib/git/lint/analyzer.rb +8 -4
- data/lib/git/lint/analyzers/abstract.rb +3 -3
- data/lib/git/lint/analyzers/commit_author_capitalization.rb +1 -1
- data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +1 -1
- data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +1 -1
- data/lib/git/lint/analyzers/{commit_body_single_bullet.rb → commit_body_bullet_only.rb} +4 -4
- data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -5
- data/lib/git/lint/analyzers/commit_body_presence.rb +3 -3
- data/lib/git/lint/analyzers/commit_body_tracker_shorthand.rb +2 -2
- data/lib/git/lint/analyzers/commit_body_word_repeat.rb +31 -0
- data/lib/git/lint/analyzers/commit_signature.rb +2 -2
- data/lib/git/lint/analyzers/commit_subject_prefix.rb +3 -3
- data/lib/git/lint/analyzers/commit_subject_suffix.rb +2 -2
- data/lib/git/lint/analyzers/commit_subject_word_repeat.rb +20 -0
- data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +2 -2
- data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +3 -4
- data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +4 -6
- data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +2 -2
- data/lib/git/lint/analyzers/commit_trailer_format_key.rb +4 -6
- data/lib/git/lint/analyzers/commit_trailer_format_value.rb +4 -4
- data/lib/git/lint/analyzers/commit_trailer_issue_key.rb +4 -6
- data/lib/git/lint/analyzers/commit_trailer_issue_value.rb +4 -4
- data/lib/git/lint/analyzers/commit_trailer_milestone_key.rb +33 -0
- data/lib/git/lint/analyzers/commit_trailer_milestone_value.rb +35 -0
- data/lib/git/lint/analyzers/commit_trailer_order.rb +38 -0
- data/lib/git/lint/analyzers/commit_trailer_reviewer_key.rb +33 -0
- data/lib/git/lint/analyzers/commit_trailer_reviewer_value.rb +35 -0
- data/lib/git/lint/analyzers/commit_trailer_signer_capitalization.rb +2 -2
- data/lib/git/lint/analyzers/commit_trailer_signer_email.rb +3 -4
- data/lib/git/lint/analyzers/commit_trailer_signer_key.rb +4 -4
- data/lib/git/lint/analyzers/commit_trailer_signer_name.rb +2 -2
- data/lib/git/lint/analyzers/commit_trailer_tracker_key.rb +4 -6
- data/lib/git/lint/analyzers/commit_trailer_tracker_value.rb +4 -4
- data/lib/git/lint/commits/{systems → hosts}/circle_ci.rb +2 -2
- data/lib/git/lint/commits/{systems → hosts}/container.rb +2 -2
- data/lib/git/lint/commits/{systems → hosts}/git_hub_action.rb +2 -2
- data/lib/git/lint/commits/{systems → hosts}/import.rb +1 -1
- data/lib/git/lint/commits/{systems → hosts}/local.rb +2 -2
- data/lib/git/lint/commits/{systems → hosts}/netlify_ci.rb +2 -2
- data/lib/git/lint/commits/loader.rb +6 -6
- data/lib/git/lint/configuration/contract.rb +19 -11
- data/lib/git/lint/configuration/defaults.yml +43 -22
- data/lib/git/lint/configuration/model.rb +19 -11
- data/lib/git/lint/configuration/trailer.rb +10 -0
- data/lib/git/lint/container.rb +28 -6
- data/lib/git/lint/errors/severity.rb +6 -1
- data/lib/git/lint/kit/filter_list.rb +9 -4
- data/lib/git/lint/reporters/branch.rb +5 -5
- data/lib/git/lint/validators/name.rb +2 -2
- data/lib/git/lint/validators/repeated_word.rb +36 -0
- data/lib/git/lint.rb +3 -1
- data.tar.gz.sig +0 -0
- metadata +40 -32
- metadata.gz.sig +0 -0
- data/lib/git/lint/analyzers/commit_body_bullet.rb +0 -34
data/lib/git/lint/analyzer.rb
CHANGED
@@ -6,25 +6,25 @@ module Git
|
|
6
6
|
class Analyzer
|
7
7
|
include Import[:configuration]
|
8
8
|
|
9
|
-
# rubocop:todo Metrics/CollectionLiteralLength
|
10
9
|
ANALYZERS = [
|
11
10
|
Analyzers::CommitAuthorCapitalization,
|
12
11
|
Analyzers::CommitAuthorEmail,
|
13
12
|
Analyzers::CommitAuthorName,
|
14
|
-
Analyzers::CommitBodyBullet,
|
15
13
|
Analyzers::CommitBodyBulletCapitalization,
|
16
14
|
Analyzers::CommitBodyBulletDelimiter,
|
15
|
+
Analyzers::CommitBodyBulletOnly,
|
17
16
|
Analyzers::CommitBodyLeadingLine,
|
18
17
|
Analyzers::CommitBodyLineLength,
|
19
18
|
Analyzers::CommitBodyParagraphCapitalization,
|
20
19
|
Analyzers::CommitBodyPhrase,
|
21
20
|
Analyzers::CommitBodyPresence,
|
22
|
-
Analyzers::CommitBodySingleBullet,
|
23
21
|
Analyzers::CommitBodyTrackerShorthand,
|
22
|
+
Analyzers::CommitBodyWordRepeat,
|
24
23
|
Analyzers::CommitSignature,
|
25
24
|
Analyzers::CommitSubjectLength,
|
26
25
|
Analyzers::CommitSubjectPrefix,
|
27
26
|
Analyzers::CommitSubjectSuffix,
|
27
|
+
Analyzers::CommitSubjectWordRepeat,
|
28
28
|
Analyzers::CommitTrailerCollaboratorCapitalization,
|
29
29
|
Analyzers::CommitTrailerCollaboratorEmail,
|
30
30
|
Analyzers::CommitTrailerCollaboratorKey,
|
@@ -34,6 +34,11 @@ module Git
|
|
34
34
|
Analyzers::CommitTrailerFormatValue,
|
35
35
|
Analyzers::CommitTrailerIssueKey,
|
36
36
|
Analyzers::CommitTrailerIssueValue,
|
37
|
+
Analyzers::CommitTrailerMilestoneKey,
|
38
|
+
Analyzers::CommitTrailerMilestoneValue,
|
39
|
+
Analyzers::CommitTrailerOrder,
|
40
|
+
Analyzers::CommitTrailerReviewerKey,
|
41
|
+
Analyzers::CommitTrailerReviewerValue,
|
37
42
|
Analyzers::CommitTrailerSignerCapitalization,
|
38
43
|
Analyzers::CommitTrailerSignerEmail,
|
39
44
|
Analyzers::CommitTrailerSignerKey,
|
@@ -41,7 +46,6 @@ module Git
|
|
41
46
|
Analyzers::CommitTrailerTrackerKey,
|
42
47
|
Analyzers::CommitTrailerTrackerValue
|
43
48
|
].freeze
|
44
|
-
# rubocop:enable Metrics/CollectionLiteralLength
|
45
49
|
|
46
50
|
# rubocop:disable Metrics/ParameterLists
|
47
51
|
def initialize(
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "core"
|
4
|
-
require "refinements/
|
4
|
+
require "refinements/string"
|
5
5
|
|
6
6
|
module Git
|
7
7
|
module Lint
|
8
8
|
module Analyzers
|
9
|
-
# An abstract class which provides basic functionality
|
9
|
+
# An abstract class which provides basic functionality for all analyzers to inherit from.
|
10
10
|
class Abstract
|
11
11
|
include Import[:configuration, :environment]
|
12
12
|
|
13
|
-
using
|
13
|
+
using Refinements::String
|
14
14
|
|
15
15
|
LEVELS = %w[warn error].freeze
|
16
16
|
BODY_OFFSET = 3
|
@@ -4,8 +4,8 @@ module Git
|
|
4
4
|
module Lint
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit bodies with only a single bullet point.
|
7
|
-
class
|
8
|
-
def valid? = affected_commit_body_lines.
|
7
|
+
class CommitBodyBulletOnly < Abstract
|
8
|
+
def valid? = !affected_commit_body_lines.one?
|
9
9
|
|
10
10
|
def issue
|
11
11
|
return {} if valid?
|
@@ -19,10 +19,10 @@ module Git
|
|
19
19
|
protected
|
20
20
|
|
21
21
|
def load_filter_list
|
22
|
-
Kit::FilterList.new configuration.
|
22
|
+
Kit::FilterList.new configuration.commits_body_bullet_only_includes
|
23
23
|
end
|
24
24
|
|
25
|
-
def invalid_line?(line) = line.match?(/\A#{Regexp.union filter_list
|
25
|
+
def invalid_line?(line) = line.match?(/\A#{Regexp.union filter_list}\s+/)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -11,7 +11,7 @@ module Git
|
|
11
11
|
return {} if valid?
|
12
12
|
|
13
13
|
{
|
14
|
-
hint: %(Avoid: #{filter_list.
|
14
|
+
hint: %(Avoid: #{filter_list.to_usage}.),
|
15
15
|
lines: affected_commit_body_lines
|
16
16
|
}
|
17
17
|
end
|
@@ -23,10 +23,7 @@ module Git
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def invalid_line? line
|
26
|
-
line.downcase.match? Regexp.new(
|
27
|
-
Regexp.union(filter_list.to_regexp).source,
|
28
|
-
Regexp::IGNORECASE
|
29
|
-
)
|
26
|
+
line.downcase.match? Regexp.new(Regexp.union(filter_list).source, Regexp::IGNORECASE)
|
30
27
|
end
|
31
28
|
end
|
32
29
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Git
|
4
4
|
module Lint
|
5
5
|
module Analyzers
|
6
|
-
# Analyzes
|
6
|
+
# Analyzes presence of commit body.
|
7
7
|
class CommitBodyPresence < Abstract
|
8
|
-
using
|
8
|
+
using Refinements::String
|
9
9
|
|
10
10
|
def valid?
|
11
11
|
return true if commit.fixup?
|
@@ -19,7 +19,7 @@ module Git
|
|
19
19
|
def issue
|
20
20
|
return {} if valid?
|
21
21
|
|
22
|
-
{hint: %(Use minimum of #{"#{minimum} line".pluralize "s",
|
22
|
+
{hint: %(Use minimum of #{"#{minimum} line".pluralize "s", minimum} (non-empty).)}
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -11,7 +11,7 @@ module Git
|
|
11
11
|
return {} if valid?
|
12
12
|
|
13
13
|
{
|
14
|
-
hint: "Explain issue instead of using shorthand. Avoid: #{filter_list.
|
14
|
+
hint: "Explain issue instead of using shorthand. Avoid: #{filter_list.to_usage}.",
|
15
15
|
lines: affected_commit_body_lines
|
16
16
|
}
|
17
17
|
end
|
@@ -22,7 +22,7 @@ module Git
|
|
22
22
|
Kit::FilterList.new configuration.commits_body_tracker_shorthand_excludes
|
23
23
|
end
|
24
24
|
|
25
|
-
def invalid_line?(line) = line.match?(/.*#{Regexp.union filter_list
|
25
|
+
def invalid_line?(line) = line.match?(/.*#{Regexp.union filter_list}.*/)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Lint
|
5
|
+
module Analyzers
|
6
|
+
# Analyzes commit body for repeated words.
|
7
|
+
class CommitBodyWordRepeat < Abstract
|
8
|
+
include Import[validator: "validators.repeated_word"]
|
9
|
+
|
10
|
+
def valid? = commit.body_lines.all? { |line| !invalid_line? line }
|
11
|
+
|
12
|
+
def issue
|
13
|
+
return {} if valid?
|
14
|
+
|
15
|
+
{
|
16
|
+
hint: "Avoid repeating these words: #{validator.call commit.body}.",
|
17
|
+
lines: affected_commit_body_lines
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def invalid_line? line
|
24
|
+
return false if line.start_with? "#"
|
25
|
+
|
26
|
+
!validator.call(line).empty?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -8,10 +8,10 @@ module Git
|
|
8
8
|
include Import[sanitizer: "sanitizers.signature"]
|
9
9
|
|
10
10
|
def valid?
|
11
|
-
sanitizer.call(commit.signature).match?(/\A#{Regexp.union filter_list
|
11
|
+
sanitizer.call(commit.signature).match?(/\A#{Regexp.union filter_list}\Z/)
|
12
12
|
end
|
13
13
|
|
14
|
-
def issue = valid? ? {} : {hint: %(Use: #{filter_list.
|
14
|
+
def issue = valid? ? {} : {hint: %(Use: #{filter_list.to_usage "or"}.)}
|
15
15
|
|
16
16
|
protected
|
17
17
|
|
@@ -9,13 +9,13 @@ module Git
|
|
9
9
|
return true if locally_prefixed?
|
10
10
|
return true if filter_list.empty?
|
11
11
|
|
12
|
-
commit.subject.match?(/\A#{Regexp.union filter_list
|
12
|
+
commit.subject.match?(/\A#{Regexp.union filter_list}/)
|
13
13
|
end
|
14
14
|
|
15
15
|
def issue
|
16
16
|
return {} if valid?
|
17
17
|
|
18
|
-
{hint: %(Use: #{filter_list.
|
18
|
+
{hint: %(Use: #{filter_list.to_usage "or"}.)}
|
19
19
|
end
|
20
20
|
|
21
21
|
protected
|
@@ -26,7 +26,7 @@ module Git
|
|
26
26
|
.then { |list| Kit::FilterList.new list }
|
27
27
|
end
|
28
28
|
|
29
|
-
def locally_prefixed? = !ci? && commit.
|
29
|
+
def locally_prefixed? = !ci? && commit.directive?
|
30
30
|
|
31
31
|
def ci? = environment["CI"] == "true"
|
32
32
|
|
@@ -8,13 +8,13 @@ module Git
|
|
8
8
|
def valid?
|
9
9
|
return true if filter_list.empty?
|
10
10
|
|
11
|
-
!commit.subject.match?(/#{Regexp.union filter_list
|
11
|
+
!commit.subject.match?(/#{Regexp.union filter_list}\Z/)
|
12
12
|
end
|
13
13
|
|
14
14
|
def issue
|
15
15
|
return {} if valid?
|
16
16
|
|
17
|
-
{hint: %(Avoid: #{filter_list.
|
17
|
+
{hint: %(Avoid: #{filter_list.to_usage}.)}
|
18
18
|
end
|
19
19
|
|
20
20
|
protected
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Lint
|
5
|
+
module Analyzers
|
6
|
+
# Analyzes commit subject for repeated words.
|
7
|
+
class CommitSubjectWordRepeat < Abstract
|
8
|
+
include Import[validator: "validators.repeated_word"]
|
9
|
+
|
10
|
+
def valid? = validator.call(commit.subject).empty?
|
11
|
+
|
12
|
+
def issue
|
13
|
+
return {} if valid?
|
14
|
+
|
15
|
+
{hint: "Avoid repeating these words: #{validator.call commit.subject}."}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,7 +6,7 @@ module Git
|
|
6
6
|
# Analyzes commit trailer collaborator name capitalization.
|
7
7
|
class CommitTrailerCollaboratorCapitalization < Abstract
|
8
8
|
include Import[
|
9
|
-
|
9
|
+
setting: "trailers.collaborator",
|
10
10
|
parser: "parsers.person",
|
11
11
|
validator: "validators.capitalization"
|
12
12
|
]
|
@@ -26,7 +26,7 @@ module Git
|
|
26
26
|
|
27
27
|
def invalid_line? trailer
|
28
28
|
parser.call(trailer.value).then do |person|
|
29
|
-
trailer.key.match?(pattern) && !validator.call(person.name)
|
29
|
+
trailer.key.match?(setting.pattern) && !validator.call(person.name)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -6,9 +6,8 @@ module Git
|
|
6
6
|
# Analyzes commit trailer collaborator email address format.
|
7
7
|
class CommitTrailerCollaboratorEmail < Abstract
|
8
8
|
include Import[
|
9
|
-
|
9
|
+
setting: "trailers.collaborator",
|
10
10
|
parser: "parsers.person",
|
11
|
-
sanitizer: "sanitizers.email",
|
12
11
|
validator: "validators.email"
|
13
12
|
]
|
14
13
|
|
@@ -26,8 +25,8 @@ module Git
|
|
26
25
|
protected
|
27
26
|
|
28
27
|
def invalid_line? trailer
|
29
|
-
email =
|
30
|
-
trailer.key.match?(pattern) && !validator.call(email)
|
28
|
+
email = parser.call(trailer.value).email
|
29
|
+
trailer.key.match?(setting.pattern) && !validator.call(email)
|
31
30
|
end
|
32
31
|
|
33
32
|
private
|
@@ -5,7 +5,7 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer collaborator key usage.
|
7
7
|
class CommitTrailerCollaboratorKey < Abstract
|
8
|
-
include Import[
|
8
|
+
include Import[setting: "trailers.collaborator"]
|
9
9
|
|
10
10
|
def valid? = affected_commit_trailers.empty?
|
11
11
|
|
@@ -13,20 +13,18 @@ module Git
|
|
13
13
|
return {} if valid?
|
14
14
|
|
15
15
|
{
|
16
|
-
hint: "Use format: #{filter_list.
|
16
|
+
hint: "Use format: #{filter_list.to_usage}.",
|
17
17
|
lines: affected_commit_trailers
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
protected
|
22
22
|
|
23
|
-
def load_filter_list
|
24
|
-
Kit::FilterList.new configuration.commits_trailer_collaborator_key_includes
|
25
|
-
end
|
23
|
+
def load_filter_list = Kit::FilterList.new setting.name
|
26
24
|
|
27
25
|
def invalid_line? trailer
|
28
26
|
trailer.key.then do |key|
|
29
|
-
key.match?(pattern) && !key.match?(/\A#{Regexp.union filter_list
|
27
|
+
key.match?(setting.pattern) && !key.match?(/\A#{Regexp.union filter_list}\Z/)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -6,7 +6,7 @@ module Git
|
|
6
6
|
# Analyzes commit trailer collaborator name construction.
|
7
7
|
class CommitTrailerCollaboratorName < Abstract
|
8
8
|
include Import[
|
9
|
-
|
9
|
+
setting: "trailers.collaborator",
|
10
10
|
parser: "parsers.person",
|
11
11
|
validator: "validators.name"
|
12
12
|
]
|
@@ -26,7 +26,7 @@ module Git
|
|
26
26
|
|
27
27
|
def invalid_line? trailer
|
28
28
|
parser.call(trailer.value).then do |person|
|
29
|
-
trailer.key.match?(pattern) && !validator.call(person.name, minimum:)
|
29
|
+
trailer.key.match?(setting.pattern) && !validator.call(person.name, minimum:)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -5,7 +5,7 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer format key usage.
|
7
7
|
class CommitTrailerFormatKey < Abstract
|
8
|
-
include Import[
|
8
|
+
include Import[setting: "trailers.format"]
|
9
9
|
|
10
10
|
def valid? = affected_commit_trailers.empty?
|
11
11
|
|
@@ -13,20 +13,18 @@ module Git
|
|
13
13
|
return {} if valid?
|
14
14
|
|
15
15
|
{
|
16
|
-
hint: "Use format: #{filter_list.
|
16
|
+
hint: "Use format: #{filter_list.to_usage}.",
|
17
17
|
lines: affected_commit_trailers
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
protected
|
22
22
|
|
23
|
-
def load_filter_list
|
24
|
-
Kit::FilterList.new configuration.commits_trailer_format_key_includes
|
25
|
-
end
|
23
|
+
def load_filter_list = Kit::FilterList.new setting.name
|
26
24
|
|
27
25
|
def invalid_line? trailer
|
28
26
|
trailer.key.then do |key|
|
29
|
-
key.match?(pattern) && !key.match?(/\A#{Regexp.union filter_list
|
27
|
+
key.match?(setting.pattern) && !key.match?(/\A#{Regexp.union filter_list}\Z/)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -5,7 +5,7 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer format value.
|
7
7
|
class CommitTrailerFormatValue < Abstract
|
8
|
-
include Import[
|
8
|
+
include Import[setting: "trailers.format"]
|
9
9
|
|
10
10
|
def valid? = affected_commit_trailers.empty?
|
11
11
|
|
@@ -13,7 +13,7 @@ module Git
|
|
13
13
|
return {} if valid?
|
14
14
|
|
15
15
|
{
|
16
|
-
hint: "Use format: #{filter_list.
|
16
|
+
hint: "Use format: #{filter_list.to_usage "or"}.",
|
17
17
|
lines: affected_commit_trailers
|
18
18
|
}
|
19
19
|
end
|
@@ -25,10 +25,10 @@ module Git
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def invalid_line? trailer
|
28
|
-
trailer.key.match?(pattern) && !trailer.value.match?(value_pattern)
|
28
|
+
trailer.key.match?(setting.pattern) && !trailer.value.match?(value_pattern)
|
29
29
|
end
|
30
30
|
|
31
|
-
def value_pattern = /\A#{Regexp.union filter_list
|
31
|
+
def value_pattern = /\A#{Regexp.union filter_list}\Z/
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -5,7 +5,7 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer issue key usage.
|
7
7
|
class CommitTrailerIssueKey < Abstract
|
8
|
-
include Import[
|
8
|
+
include Import[setting: "trailers.issue"]
|
9
9
|
|
10
10
|
def valid? = affected_commit_trailers.empty?
|
11
11
|
|
@@ -13,20 +13,18 @@ module Git
|
|
13
13
|
return {} if valid?
|
14
14
|
|
15
15
|
{
|
16
|
-
hint: "Use format: #{filter_list.
|
16
|
+
hint: "Use format: #{filter_list.to_usage}.",
|
17
17
|
lines: affected_commit_trailers
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
protected
|
22
22
|
|
23
|
-
def load_filter_list
|
24
|
-
Kit::FilterList.new configuration.commits_trailer_issue_key_includes
|
25
|
-
end
|
23
|
+
def load_filter_list = Kit::FilterList.new setting.name
|
26
24
|
|
27
25
|
def invalid_line? trailer
|
28
26
|
trailer.key.then do |key|
|
29
|
-
key.match?(pattern) && !key.match?(/\A#{Regexp.union filter_list
|
27
|
+
key.match?(setting.pattern) && !key.match?(/\A#{Regexp.union filter_list}\Z/)
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -5,7 +5,7 @@ module Git
|
|
5
5
|
module Analyzers
|
6
6
|
# Analyzes commit trailer issue value.
|
7
7
|
class CommitTrailerIssueValue < Abstract
|
8
|
-
include Import[
|
8
|
+
include Import[setting: "trailers.issue"]
|
9
9
|
|
10
10
|
def valid? = affected_commit_trailers.empty?
|
11
11
|
|
@@ -13,7 +13,7 @@ module Git
|
|
13
13
|
return {} if valid?
|
14
14
|
|
15
15
|
{
|
16
|
-
hint: "Use format: #{filter_list.
|
16
|
+
hint: "Use format: #{filter_list.to_usage}.",
|
17
17
|
lines: affected_commit_trailers
|
18
18
|
}
|
19
19
|
end
|
@@ -25,10 +25,10 @@ module Git
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def invalid_line? trailer
|
28
|
-
trailer.key.match?(pattern) && !trailer.value.match?(value_pattern)
|
28
|
+
trailer.key.match?(setting.pattern) && !trailer.value.match?(value_pattern)
|
29
29
|
end
|
30
30
|
|
31
|
-
def value_pattern = /\A#{Regexp.union filter_list
|
31
|
+
def value_pattern = /\A#{Regexp.union filter_list}\Z/
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Lint
|
5
|
+
module Analyzers
|
6
|
+
# Analyzes commit trailer milestone key usage.
|
7
|
+
class CommitTrailerMilestoneKey < Abstract
|
8
|
+
include Import[setting: "trailers.milestone"]
|
9
|
+
|
10
|
+
def valid? = affected_commit_trailers.empty?
|
11
|
+
|
12
|
+
def issue
|
13
|
+
return {} if valid?
|
14
|
+
|
15
|
+
{
|
16
|
+
hint: "Use: #{filter_list.to_usage}.",
|
17
|
+
lines: affected_commit_trailers
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def load_filter_list = Kit::FilterList.new setting.name
|
24
|
+
|
25
|
+
def invalid_line? trailer
|
26
|
+
trailer.key.then do |key|
|
27
|
+
key.match?(setting.pattern) && !key.match?(/\A#{Regexp.union filter_list}\Z/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Lint
|
5
|
+
module Analyzers
|
6
|
+
# Analyzes commit trailer milestone value.
|
7
|
+
class CommitTrailerMilestoneValue < Abstract
|
8
|
+
include Import[setting: "trailers.milestone"]
|
9
|
+
|
10
|
+
def valid? = affected_commit_trailers.empty?
|
11
|
+
|
12
|
+
def issue
|
13
|
+
return {} if valid?
|
14
|
+
|
15
|
+
{
|
16
|
+
hint: "Use: #{filter_list.to_usage "or"}.",
|
17
|
+
lines: affected_commit_trailers
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def load_filter_list
|
24
|
+
Kit::FilterList.new configuration.commits_trailer_milestone_value_includes
|
25
|
+
end
|
26
|
+
|
27
|
+
def invalid_line? trailer
|
28
|
+
trailer.key.match?(setting.pattern) && !trailer.value.match?(value_pattern)
|
29
|
+
end
|
30
|
+
|
31
|
+
def value_pattern = /\A#{Regexp.union filter_list}\Z/
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Lint
|
5
|
+
module Analyzers
|
6
|
+
# Analyzes commit trailer order value.
|
7
|
+
class CommitTrailerOrder < Abstract
|
8
|
+
def initialize(...)
|
9
|
+
super
|
10
|
+
@original_order = commit.trailers.map(&:key)
|
11
|
+
@sorted_order = original_order.sort
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid? = original_order == sorted_order
|
15
|
+
|
16
|
+
def issue
|
17
|
+
return {} if valid?
|
18
|
+
|
19
|
+
{
|
20
|
+
hint: "Ensure keys are alphabetically sorted.",
|
21
|
+
lines: affected_commit_trailers
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def invalid_line? trailer
|
28
|
+
key = trailer.key
|
29
|
+
original_order.index(key) != sorted_order.index(key)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
attr_reader :original_order, :sorted_order
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Lint
|
5
|
+
module Analyzers
|
6
|
+
# Analyzes commit trailer reviwer key usage.
|
7
|
+
class CommitTrailerReviewerKey < Abstract
|
8
|
+
include Import[setting: "trailers.reviewer"]
|
9
|
+
|
10
|
+
def valid? = affected_commit_trailers.empty?
|
11
|
+
|
12
|
+
def issue
|
13
|
+
return {} if valid?
|
14
|
+
|
15
|
+
{
|
16
|
+
hint: "Use: #{filter_list.to_usage}.",
|
17
|
+
lines: affected_commit_trailers
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def load_filter_list = Kit::FilterList.new setting.name
|
24
|
+
|
25
|
+
def invalid_line? trailer
|
26
|
+
trailer.key.then do |key|
|
27
|
+
key.match?(setting.pattern) && !key.match?(/\A#{Regexp.union filter_list}\Z/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|