git-lint 2.0.0 → 2.3.1

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 (49) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +2 -2
  4. data/README.adoc +37 -139
  5. data/lib/git/lint/analyzers/abstract.rb +9 -27
  6. data/lib/git/lint/analyzers/commit_author_capitalization.rb +1 -3
  7. data/lib/git/lint/analyzers/commit_author_email.rb +1 -3
  8. data/lib/git/lint/analyzers/commit_author_name.rb +1 -3
  9. data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -6
  10. data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +3 -9
  11. data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +4 -12
  12. data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +3 -9
  13. data/lib/git/lint/analyzers/commit_body_line_length.rb +3 -9
  14. data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +3 -9
  15. data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -6
  16. data/lib/git/lint/analyzers/commit_body_presence.rb +2 -4
  17. data/lib/git/lint/analyzers/commit_body_single_bullet.rb +3 -9
  18. data/lib/git/lint/analyzers/commit_subject_length.rb +2 -6
  19. data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -10
  20. data/lib/git/lint/analyzers/commit_subject_suffix.rb +1 -3
  21. data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +1 -3
  22. data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +1 -3
  23. data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +1 -3
  24. data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +2 -6
  25. data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +2 -6
  26. data/lib/git/lint/branches/environments/circle_ci.rb +2 -6
  27. data/lib/git/lint/branches/environments/git_hub_action.rb +2 -6
  28. data/lib/git/lint/branches/environments/local.rb +2 -6
  29. data/lib/git/lint/branches/environments/netlify_ci.rb +2 -4
  30. data/lib/git/lint/branches/environments/travis_ci.rb +6 -14
  31. data/lib/git/lint/branches/feature.rb +1 -3
  32. data/lib/git/lint/cli.rb +1 -4
  33. data/lib/git/lint/collector.rb +11 -31
  34. data/lib/git/lint/identity.rb +1 -1
  35. data/lib/git/lint/kit/filter_list.rb +3 -9
  36. data/lib/git/lint/parsers/trailers/collaborator.rb +4 -12
  37. data/lib/git/lint/rake/tasks.rb +1 -3
  38. data/lib/git/lint/refinements/strings.rb +2 -6
  39. data/lib/git/lint/reporters/branch.rb +1 -1
  40. data/lib/git/lint/reporters/commit.rb +1 -3
  41. data/lib/git/lint/reporters/line.rb +1 -3
  42. data/lib/git/lint/reporters/lines/paragraph.rb +5 -15
  43. data/lib/git/lint/reporters/lines/sentence.rb +3 -9
  44. data/lib/git/lint/reporters/style.rb +1 -3
  45. data/lib/git/lint/validators/capitalization.rb +2 -6
  46. data/lib/git/lint/validators/email.rb +1 -3
  47. data/lib/git/lint/validators/name.rb +2 -6
  48. metadata +15 -15
  49. metadata.gz.sig +0 -0
@@ -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,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 fixup_or_squash?
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.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
@@ -30,9 +30,7 @@ module Git
30
30
 
31
31
  protected
32
32
 
33
- def load_filter_list
34
- Kit::FilterList.new settings.fetch(:excludes)
35
- end
33
+ def load_filter_list = Kit::FilterList.new(settings.fetch(:excludes))
36
34
  end
37
35
  end
38
36
  end
@@ -22,9 +22,7 @@ module Git
22
22
  end
23
23
  # rubocop:enable Metrics/ParameterLists
24
24
 
25
- def valid?
26
- affected_commit_trailers.empty?
27
- end
25
+ def valid? = affected_commit_trailers.empty?
28
26
 
29
27
  def issue
30
28
  return {} if valid?
@@ -19,9 +19,7 @@ module Git
19
19
  @tally = build_tally
20
20
  end
21
21
 
22
- def valid?
23
- affected_commit_trailers.empty?
24
- end
22
+ def valid? = affected_commit_trailers.empty?
25
23
 
26
24
  def issue
27
25
  return {} if valid?
@@ -23,9 +23,7 @@ module Git
23
23
  end
24
24
  # rubocop:enable Metrics/ParameterLists
25
25
 
26
- def valid?
27
- affected_commit_trailers.empty?
28
- end
26
+ def valid? = affected_commit_trailers.empty?
29
27
 
30
28
  def issue
31
29
  return {} if valid?
@@ -19,9 +19,7 @@ module Git
19
19
  @parser = parser
20
20
  end
21
21
 
22
- def valid?
23
- affected_commit_trailers.empty?
24
- end
22
+ def valid? = affected_commit_trailers.empty?
25
23
 
26
24
  def issue
27
25
  return {} if valid?
@@ -34,9 +32,7 @@ module Git
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
@@ -24,9 +24,7 @@ module Git
24
24
  end
25
25
  # rubocop:enable Metrics/ParameterLists
26
26
 
27
- def valid?
28
- affected_commit_trailers.empty?
29
- end
27
+ def valid? = affected_commit_trailers.empty?
30
28
 
31
29
  def issue
32
30
  return {} if valid?
@@ -48,9 +46,7 @@ module Git
48
46
 
49
47
  attr_reader :parser, :validator
50
48
 
51
- def minimum
52
- settings.fetch :minimum
53
- end
49
+ def minimum = settings.fetch(:minimum)
54
50
  end
55
51
  end
56
52
  end
@@ -10,13 +10,9 @@ module Git
10
10
  @repository = repository
11
11
  end
12
12
 
13
- def name
14
- "origin/#{repository.branch_name}"
15
- end
13
+ def name = "origin/#{repository.branch_name}"
16
14
 
17
- def commits
18
- repository.commits "origin/master..#{name}"
19
- end
15
+ def commits = repository.commits("origin/#{repository.branch_default}..#{name}")
20
16
 
21
17
  private
22
18
 
@@ -10,13 +10,9 @@ module Git
10
10
  @repository = repository
11
11
  end
12
12
 
13
- def name
14
- "origin/#{repository.branch_name}"
15
- end
13
+ def name = "origin/#{repository.branch_name}"
16
14
 
17
- def commits
18
- repository.commits "origin/master..#{name}"
19
- end
15
+ def commits = repository.commits("origin/#{repository.branch_default}..#{name}")
20
16
 
21
17
  private
22
18
 
@@ -10,13 +10,9 @@ module Git
10
10
  @repository = repository
11
11
  end
12
12
 
13
- def name
14
- repository.branch_name
15
- end
13
+ def name = repository.branch_name
16
14
 
17
- def commits
18
- repository.commits "master..#{name}"
19
- end
15
+ def commits = repository.commits("#{repository.branch_default}..#{name}")
20
16
 
21
17
  private
22
18
 
@@ -14,14 +14,12 @@ module Git
14
14
  @environment = environment
15
15
  end
16
16
 
17
- def name
18
- environment["HEAD"]
19
- end
17
+ def name = environment["HEAD"]
20
18
 
21
19
  def commits
22
20
  shell.capture3 "git remote add -f origin #{environment["REPOSITORY_URL"]}"
23
21
  shell.capture3 "git fetch origin #{name}:#{name}"
24
- repository.commits "origin/master..origin/#{name}"
22
+ repository.commits "origin/#{repository.branch_default}..origin/#{name}"
25
23
  end
26
24
 
27
25
  private
@@ -14,13 +14,11 @@ module Git
14
14
  @environment = environment
15
15
  end
16
16
 
17
- def name
18
- pull_request_branch.empty? ? ci_branch : pull_request_branch
19
- end
17
+ def name = pull_request_branch.empty? ? ci_branch : pull_request_branch
20
18
 
21
19
  def commits
22
20
  prepare_project
23
- repository.commits "origin/master..#{name}"
21
+ repository.commits "origin/#{repository.branch_default}..#{name}"
24
22
  end
25
23
 
26
24
  private
@@ -35,21 +33,15 @@ module Git
35
33
  shell.capture3 "git fetch original_branch #{name}:#{name}"
36
34
  end
37
35
 
38
- shell.capture3 "git remote set-branches --add origin master"
36
+ shell.capture3 "git remote set-branches --add origin #{repository.branch_default}"
39
37
  shell.capture3 "git fetch"
40
38
  end
41
39
 
42
- def ci_branch
43
- environment["TRAVIS_BRANCH"]
44
- end
40
+ def ci_branch = environment["TRAVIS_BRANCH"]
45
41
 
46
- def pull_request_branch
47
- environment["TRAVIS_PULL_REQUEST_BRANCH"]
48
- end
42
+ def pull_request_branch = environment["TRAVIS_PULL_REQUEST_BRANCH"]
49
43
 
50
- def pull_request_slug
51
- environment["TRAVIS_PULL_REQUEST_SLUG"]
52
- end
44
+ def pull_request_slug = environment["TRAVIS_PULL_REQUEST_SLUG"]
53
45
  end
54
46
  end
55
47
  end
@@ -35,9 +35,7 @@ module Git
35
35
  end
36
36
  end
37
37
 
38
- def key? key
39
- current_environment.fetch(key, "false").to_bool
40
- end
38
+ def key?(key) = current_environment.fetch(key, "false").to_bool
41
39
  end
42
40
  end
43
41
  end