git-lint 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.adoc +207 -155
- data/README.adoc +201 -203
- data/{bin → exe}/git-lint +1 -3
- data/lib/git/lint/analyzer.rb +76 -0
- data/lib/git/lint/analyzers/abstract.rb +8 -18
- data/lib/git/lint/analyzers/commit_author_capitalization.rb +3 -9
- data/lib/git/lint/analyzers/commit_author_email.rb +3 -9
- data/lib/git/lint/analyzers/commit_author_name.rb +5 -14
- data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_leading_line.rb +1 -7
- data/lib/git/lint/analyzers/commit_body_line_length.rb +4 -11
- data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +1 -7
- data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -38
- data/lib/git/lint/analyzers/commit_body_presence.rb +4 -11
- data/lib/git/lint/analyzers/commit_body_single_bullet.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_tracker_shorthand.rb +27 -0
- data/lib/git/lint/analyzers/commit_subject_length.rb +4 -11
- data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -9
- data/lib/git/lint/analyzers/commit_subject_suffix.rb +2 -13
- data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +3 -12
- data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +3 -11
- data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +3 -12
- data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +4 -13
- data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +5 -15
- data/lib/git/lint/cli/actions/analyze/branch.rb +43 -0
- data/lib/git/lint/cli/actions/analyze/commit.rb +44 -0
- data/lib/git/lint/cli/actions/config.rb +37 -0
- data/lib/git/lint/cli/actions/hook.rb +34 -0
- data/lib/git/lint/cli/parser.rb +33 -0
- data/lib/git/lint/cli/parsers/analyze.rb +40 -0
- data/lib/git/lint/cli/parsers/core.rb +72 -0
- data/lib/git/lint/cli/shell.rb +56 -0
- data/lib/git/lint/collector.rb +3 -4
- data/lib/git/lint/commits/container.rb +19 -0
- data/lib/git/lint/commits/loader.rb +51 -0
- data/lib/git/lint/commits/systems/circle_ci.rb +26 -0
- data/lib/git/lint/{branches/environments → commits/systems}/git_hub_action.rb +10 -8
- data/lib/git/lint/commits/systems/local.rb +26 -0
- data/lib/git/lint/{branches/environments → commits/systems}/netlify_ci.rb +14 -10
- data/lib/git/lint/configuration/content.rb +26 -0
- data/lib/git/lint/configuration/defaults.yml +118 -0
- data/lib/git/lint/configuration/loader.rb +50 -0
- data/lib/git/lint/configuration/setting.rb +24 -0
- data/lib/git/lint/container.rb +41 -0
- data/lib/git/lint/errors/severity.rb +1 -0
- data/lib/git/lint/errors/sha.rb +1 -0
- data/lib/git/lint/identity.rb +2 -1
- data/lib/git/lint/kit/filter_list.rb +1 -1
- data/lib/git/lint/parsers/trailers/collaborator.rb +1 -0
- data/lib/git/lint/rake/tasks.rb +5 -4
- data/lib/git/lint/reporters/branch.rb +12 -6
- data/lib/git/lint/reporters/commit.rb +3 -1
- data/lib/git/lint/reporters/line.rb +3 -5
- data/lib/git/lint/reporters/lines/paragraph.rb +3 -0
- data/lib/git/lint/reporters/lines/sentence.rb +3 -0
- data/lib/git/lint/reporters/style.rb +3 -1
- data/lib/git/lint/validators/capitalization.rb +1 -0
- data/lib/git/lint/validators/email.rb +1 -0
- data/lib/git/lint/validators/name.rb +1 -0
- data/lib/git/lint.rb +18 -47
- data.tar.gz.sig +0 -0
- metadata +54 -28
- metadata.gz.sig +0 -0
- data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +0 -39
- data/lib/git/lint/branches/environments/circle_ci.rb +0 -24
- data/lib/git/lint/branches/environments/local.rb +0 -24
- data/lib/git/lint/branches/environments/travis_ci.rb +0 -49
- data/lib/git/lint/branches/feature.rb +0 -42
- data/lib/git/lint/cli.rb +0 -117
- data/lib/git/lint/refinements/strings.rb +0 -21
- data/lib/git/lint/runner.rb +0 -35
@@ -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
|
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
|
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
|
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:
|
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.
|
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.
|
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.
|
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 #{
|
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 >
|
21
|
+
def invalid_line?(line) = line.length > maximum
|
29
22
|
|
30
23
|
private
|
31
24
|
|
32
|
-
def
|
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.
|
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,16 +3,9 @@
|
|
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
|
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?
|
@@ -21,12 +14,12 @@ module Git
|
|
21
14
|
valid_lines.size >= minimum
|
22
15
|
end
|
23
16
|
|
24
|
-
def minimum = settings.
|
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.
|
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
|
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 #{
|
13
|
+
{hint: "Use #{maximum} characters or less."}
|
21
14
|
end
|
22
15
|
|
23
16
|
private
|
24
17
|
|
25
|
-
def
|
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.
|
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.
|
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
|
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
|
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
|
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
|
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
|
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
|
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.
|
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
|
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
|
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:
|
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.
|
39
|
+
def minimum = settings.minimum
|
50
40
|
end
|
51
41
|
end
|
52
42
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Git
|
4
|
+
module Lint
|
5
|
+
module CLI
|
6
|
+
module Actions
|
7
|
+
module Analyze
|
8
|
+
# Handles analyze action for branch.
|
9
|
+
class Branch
|
10
|
+
def initialize analyzer: Analyzer.new, container: Container
|
11
|
+
@analyzer = analyzer
|
12
|
+
@container = container
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
parse
|
17
|
+
rescue Errors::Base => error
|
18
|
+
logger.error { error.message }
|
19
|
+
kernel.abort
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :analyzer, :container
|
25
|
+
|
26
|
+
def parse
|
27
|
+
analyzer.call do |collector, reporter|
|
28
|
+
kernel.puts reporter
|
29
|
+
kernel.abort if collector.errors?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def repository = container[__method__]
|
34
|
+
|
35
|
+
def kernel = container[__method__]
|
36
|
+
|
37
|
+
def logger = container[__method__]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|