git-lint 1.4.0 → 2.3.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.tar.gz.sig +0 -0
- data/README.adoc +37 -139
- data/lib/git/lint.rb +18 -50
- data/lib/git/lint/analyzers/abstract.rb +12 -30
- data/lib/git/lint/analyzers/commit_author_capitalization.rb +1 -3
- data/lib/git/lint/analyzers/commit_author_email.rb +1 -3
- data/lib/git/lint/analyzers/commit_author_name.rb +2 -4
- data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -6
- data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +4 -12
- data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_leading_line.rb +3 -3
- data/lib/git/lint/analyzers/commit_body_line_length.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +3 -9
- data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -6
- data/lib/git/lint/analyzers/commit_body_presence.rb +2 -4
- data/lib/git/lint/analyzers/commit_body_single_bullet.rb +3 -9
- data/lib/git/lint/analyzers/commit_subject_length.rb +2 -6
- data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -10
- data/lib/git/lint/analyzers/commit_subject_suffix.rb +1 -3
- data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +2 -4
- data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +3 -5
- data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +2 -4
- data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +3 -7
- data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +3 -7
- data/lib/git/lint/branches/environments/circle_ci.rb +5 -9
- data/lib/git/lint/branches/environments/git_hub_action.rb +5 -9
- data/lib/git/lint/branches/environments/local.rb +5 -9
- data/lib/git/lint/branches/environments/netlify_ci.rb +9 -11
- data/lib/git/lint/branches/environments/travis_ci.rb +14 -22
- data/lib/git/lint/branches/feature.rb +6 -9
- data/lib/git/lint/cli.rb +10 -15
- data/lib/git/lint/collector.rb +12 -32
- data/lib/git/lint/identity.rb +1 -1
- data/lib/git/lint/kit/filter_list.rb +3 -9
- data/lib/git/lint/parsers/trailers/collaborator.rb +6 -14
- data/lib/git/lint/rake/tasks.rb +1 -3
- data/lib/git/lint/refinements/strings.rb +2 -6
- data/lib/git/lint/reporters/branch.rb +15 -15
- data/lib/git/lint/reporters/commit.rb +1 -3
- data/lib/git/lint/reporters/line.rb +1 -3
- data/lib/git/lint/reporters/lines/paragraph.rb +5 -15
- data/lib/git/lint/reporters/lines/sentence.rb +3 -9
- data/lib/git/lint/reporters/style.rb +1 -3
- data/lib/git/lint/runner.rb +5 -4
- data/lib/git/lint/validators/capitalization.rb +3 -7
- data/lib/git/lint/validators/email.rb +1 -3
- data/lib/git/lint/validators/name.rb +3 -7
- metadata +46 -21
- metadata.gz.sig +0 -0
- data/lib/git/kit/repo.rb +0 -30
- data/lib/git/lint/commits/saved.rb +0 -104
- data/lib/git/lint/commits/unsaved.rb +0 -120
@@ -17,9 +17,7 @@ module Git
|
|
17
17
|
@validator = validator
|
18
18
|
end
|
19
19
|
|
20
|
-
def valid?
|
21
|
-
validator.new(commit.author_name, minimum: minimum).valid?
|
22
|
-
end
|
20
|
+
def valid? = validator.new(commit.author_name, minimum: minimum).valid?
|
23
21
|
|
24
22
|
def issue
|
25
23
|
return {} if valid?
|
@@ -32,7 +30,7 @@ module Git
|
|
32
30
|
attr_reader :validator
|
33
31
|
|
34
32
|
def minimum
|
35
|
-
settings.fetch
|
33
|
+
settings.fetch __method__
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.body_lines.all? { |line| !invalid_line? line }
|
17
|
-
end
|
15
|
+
def valid? = commit.body_lines.all? { |line| !invalid_line? line }
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,9 +25,7 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :excludes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
|
33
29
|
|
34
30
|
# :reek:FeatureEnvy
|
35
31
|
def invalid_line? line
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
lowercased_bullets.size.zero?
|
17
|
-
end
|
15
|
+
def valid? = lowercased_bullets.size.zero?
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,9 +25,7 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :includes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
33
29
|
|
34
30
|
def invalid_line? line
|
35
31
|
line.match?(/\A\s*#{Regexp.union filter_list.to_regexp}\s[[:lower:]]+/)
|
@@ -37,9 +33,7 @@ module Git
|
|
37
33
|
|
38
34
|
private
|
39
35
|
|
40
|
-
def lowercased_bullets
|
41
|
-
commit.body_lines.select { |line| invalid_line? line }
|
42
|
-
end
|
36
|
+
def lowercased_bullets = commit.body_lines.select { |line| invalid_line? line }
|
43
37
|
end
|
44
38
|
end
|
45
39
|
end
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.body_lines.none? { |line| invalid_line? line }
|
17
|
-
end
|
15
|
+
def valid? = commit.body_lines.none? { |line| invalid_line? line }
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,17 +25,11 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :includes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
33
29
|
|
34
|
-
def invalid_line? line
|
35
|
-
line.match?(/\A\s*#{pattern}(?!(#{pattern}|\s)).+\Z/)
|
36
|
-
end
|
30
|
+
def invalid_line?(line) = line.match?(/\A\s*#{pattern}(?!(#{pattern}|\s)).+\Z/)
|
37
31
|
|
38
|
-
def pattern
|
39
|
-
Regexp.union filter_list.to_regexp
|
40
|
-
end
|
32
|
+
def pattern = Regexp.union(filter_list.to_regexp)
|
41
33
|
end
|
42
34
|
end
|
43
35
|
end
|
@@ -17,9 +17,7 @@ module Git
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
def valid?
|
21
|
-
commit.body_lines.none? { |line| invalid_line? line }
|
22
|
-
end
|
20
|
+
def valid? = commit.body_lines.none? { |line| invalid_line? line }
|
23
21
|
|
24
22
|
def issue
|
25
23
|
return {} if valid?
|
@@ -32,13 +30,9 @@ module Git
|
|
32
30
|
|
33
31
|
protected
|
34
32
|
|
35
|
-
def load_filter_list
|
36
|
-
Kit::FilterList.new settings.fetch :excludes
|
37
|
-
end
|
33
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
|
38
34
|
|
39
|
-
def invalid_line? line
|
40
|
-
line.match?(/.*#{Regexp.union filter_list.to_regexp}.*/)
|
41
|
-
end
|
35
|
+
def invalid_line?(line) = line.match?(/.*#{Regexp.union filter_list.to_regexp}.*/)
|
42
36
|
end
|
43
37
|
end
|
44
38
|
end
|
@@ -12,12 +12,12 @@ module Git
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def valid?
|
15
|
-
|
16
|
-
subject, body =
|
15
|
+
message = commit.message
|
16
|
+
subject, body = message.split "\n", 2
|
17
17
|
|
18
18
|
return true if !String(subject).empty? && String(body).strip.empty?
|
19
19
|
|
20
|
-
|
20
|
+
message.match?(/\A.+(\n\n|\#).+/m)
|
21
21
|
end
|
22
22
|
|
23
23
|
def issue
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.body_lines.all? { |line| !invalid_line? line }
|
17
|
-
end
|
15
|
+
def valid? = commit.body_lines.all? { |line| !invalid_line? line }
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,15 +25,11 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def invalid_line? line
|
31
|
-
line.length > length
|
32
|
-
end
|
28
|
+
def invalid_line?(line) = line.length > length
|
33
29
|
|
34
30
|
private
|
35
31
|
|
36
|
-
def length
|
37
|
-
settings.fetch :length
|
38
|
-
end
|
32
|
+
def length = settings.fetch(:length)
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
@@ -11,13 +11,9 @@ module Git
|
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.invalid? line
|
15
|
-
line.match?(/\A[[:lower:]].+\Z/m)
|
16
|
-
end
|
14
|
+
def self.invalid?(line) = line.match?(/\A[[:lower:]].+\Z/m)
|
17
15
|
|
18
|
-
def valid?
|
19
|
-
lowercased_lines.empty?
|
20
|
-
end
|
16
|
+
def valid? = lowercased_lines.empty?
|
21
17
|
|
22
18
|
def issue
|
23
19
|
return {} if valid?
|
@@ -30,9 +26,7 @@ module Git
|
|
30
26
|
|
31
27
|
private
|
32
28
|
|
33
|
-
def lowercased_lines
|
34
|
-
commit.body_paragraphs.select { |line| self.class.invalid? line }
|
35
|
-
end
|
29
|
+
def lowercased_lines = commit.body_paragraphs.select { |line| self.class.invalid? line }
|
36
30
|
|
37
31
|
def affected_lines
|
38
32
|
klass = self.class
|
@@ -41,9 +41,7 @@ module Git
|
|
41
41
|
end
|
42
42
|
# rubocop:enable Metrics/MethodLength
|
43
43
|
|
44
|
-
def valid?
|
45
|
-
commit.body_lines.all? { |line| !invalid_line? line }
|
46
|
-
end
|
44
|
+
def valid? = commit.body_lines.all? { |line| !invalid_line? line }
|
47
45
|
|
48
46
|
def issue
|
49
47
|
return {} if valid?
|
@@ -56,9 +54,7 @@ module Git
|
|
56
54
|
|
57
55
|
protected
|
58
56
|
|
59
|
-
def load_filter_list
|
60
|
-
Kit::FilterList.new settings.fetch(:excludes)
|
61
|
-
end
|
57
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
|
62
58
|
|
63
59
|
def invalid_line? line
|
64
60
|
line.downcase.match? Regexp.new(
|
@@ -4,7 +4,7 @@ module Git
|
|
4
4
|
module Lint
|
5
5
|
module Analyzers
|
6
6
|
class CommitBodyPresence < Abstract
|
7
|
-
using Refinements::Strings
|
7
|
+
using GitPlus::Refinements::Strings
|
8
8
|
|
9
9
|
def self.defaults
|
10
10
|
{
|
@@ -21,9 +21,7 @@ module Git
|
|
21
21
|
valid_lines.size >= minimum
|
22
22
|
end
|
23
23
|
|
24
|
-
def minimum
|
25
|
-
settings.fetch :minimum
|
26
|
-
end
|
24
|
+
def minimum = settings.fetch(:minimum)
|
27
25
|
|
28
26
|
def issue
|
29
27
|
return {} if valid?
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
affected_commit_body_lines.size != 1
|
17
|
-
end
|
15
|
+
def valid? = affected_commit_body_lines.size != 1
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -27,13 +25,9 @@ module Git
|
|
27
25
|
|
28
26
|
protected
|
29
27
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch :includes
|
32
|
-
end
|
28
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
33
29
|
|
34
|
-
def invalid_line? line
|
35
|
-
line.match?(/\A#{Regexp.union filter_list.to_regexp}\s+/)
|
36
|
-
end
|
30
|
+
def invalid_line?(line) = line.match?(/\A#{Regexp.union filter_list.to_regexp}\s+/)
|
37
31
|
end
|
38
32
|
end
|
39
33
|
end
|
@@ -12,9 +12,7 @@ module Git
|
|
12
12
|
}
|
13
13
|
end
|
14
14
|
|
15
|
-
def valid?
|
16
|
-
commit.subject.sub(/(fixup!|squash!)\s{1}/, "").size <= length
|
17
|
-
end
|
15
|
+
def valid? = commit.subject.sub(/(fixup!|squash!)\s{1}/, "").size <= length
|
18
16
|
|
19
17
|
def issue
|
20
18
|
return {} if valid?
|
@@ -24,9 +22,7 @@ module Git
|
|
24
22
|
|
25
23
|
private
|
26
24
|
|
27
|
-
def length
|
28
|
-
settings.fetch :length
|
29
|
-
end
|
25
|
+
def length = settings.fetch(:length)
|
30
26
|
end
|
31
27
|
end
|
32
28
|
end
|
@@ -13,7 +13,7 @@ module Git
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def valid?
|
16
|
-
return true if
|
16
|
+
return true if commit.prefix?
|
17
17
|
return true if filter_list.empty?
|
18
18
|
|
19
19
|
commit.subject.match?(/\A#{Regexp.union filter_list.to_regexp}/)
|
@@ -27,15 +27,7 @@ module Git
|
|
27
27
|
|
28
28
|
protected
|
29
29
|
|
30
|
-
def load_filter_list
|
31
|
-
Kit::FilterList.new settings.fetch(:includes)
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def fixup_or_squash?
|
37
|
-
commit.is_a?(Git::Lint::Commits::Unsaved) && (commit.fixup? || commit.squash?)
|
38
|
-
end
|
30
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
39
31
|
end
|
40
32
|
end
|
41
33
|
end
|
@@ -22,16 +22,14 @@ module Git
|
|
22
22
|
end
|
23
23
|
# rubocop:enable Metrics/ParameterLists
|
24
24
|
|
25
|
-
def valid?
|
26
|
-
affected_commit_trailer_lines.empty?
|
27
|
-
end
|
25
|
+
def valid? = affected_commit_trailers.empty?
|
28
26
|
|
29
27
|
def issue
|
30
28
|
return {} if valid?
|
31
29
|
|
32
30
|
{
|
33
31
|
hint: "Name must be capitalized.",
|
34
|
-
lines:
|
32
|
+
lines: affected_commit_trailers
|
35
33
|
}
|
36
34
|
end
|
37
35
|
|
@@ -19,16 +19,14 @@ module Git
|
|
19
19
|
@tally = build_tally
|
20
20
|
end
|
21
21
|
|
22
|
-
def valid?
|
23
|
-
affected_commit_trailer_lines.empty?
|
24
|
-
end
|
22
|
+
def valid? = affected_commit_trailers.empty?
|
25
23
|
|
26
24
|
def issue
|
27
25
|
return {} if valid?
|
28
26
|
|
29
27
|
{
|
30
28
|
hint: "Avoid duplication.",
|
31
|
-
lines:
|
29
|
+
lines: affected_commit_trailers
|
32
30
|
}
|
33
31
|
end
|
34
32
|
|
@@ -47,7 +45,7 @@ module Git
|
|
47
45
|
zeros = Hash.new { |new_hash, missing_key| new_hash[missing_key] = 0 }
|
48
46
|
|
49
47
|
zeros.tap do |collection|
|
50
|
-
commit.
|
48
|
+
commit.trailers.each { |line| collection[line] += 1 if parser.new(line).match? }
|
51
49
|
end
|
52
50
|
end
|
53
51
|
end
|
@@ -23,16 +23,14 @@ module Git
|
|
23
23
|
end
|
24
24
|
# rubocop:enable Metrics/ParameterLists
|
25
25
|
|
26
|
-
def valid?
|
27
|
-
affected_commit_trailer_lines.empty?
|
28
|
-
end
|
26
|
+
def valid? = affected_commit_trailers.empty?
|
29
27
|
|
30
28
|
def issue
|
31
29
|
return {} if valid?
|
32
30
|
|
33
31
|
{
|
34
32
|
hint: %(Email must follow name and use format: "<name@server.domain>".),
|
35
|
-
lines:
|
33
|
+
lines: affected_commit_trailers
|
36
34
|
}
|
37
35
|
end
|
38
36
|
|
@@ -19,24 +19,20 @@ module Git
|
|
19
19
|
@parser = parser
|
20
20
|
end
|
21
21
|
|
22
|
-
def valid?
|
23
|
-
affected_commit_trailer_lines.empty?
|
24
|
-
end
|
22
|
+
def valid? = affected_commit_trailers.empty?
|
25
23
|
|
26
24
|
def issue
|
27
25
|
return {} if valid?
|
28
26
|
|
29
27
|
{
|
30
28
|
hint: "Use format: #{filter_list.to_hint}.",
|
31
|
-
lines:
|
29
|
+
lines: affected_commit_trailers
|
32
30
|
}
|
33
31
|
end
|
34
32
|
|
35
33
|
protected
|
36
34
|
|
37
|
-
def load_filter_list
|
38
|
-
Kit::FilterList.new settings.fetch :includes
|
39
|
-
end
|
35
|
+
def load_filter_list = Kit::FilterList.new(settings.fetch(:includes))
|
40
36
|
|
41
37
|
def invalid_line? line
|
42
38
|
collaborator = parser.new line
|