git-lint 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.adoc +2 -2
  5. data/lib/git/lint.rb +17 -47
  6. data/lib/git/lint/analyzers/abstract.rb +9 -27
  7. data/lib/git/lint/analyzers/commit_author_capitalization.rb +1 -3
  8. data/lib/git/lint/analyzers/commit_author_email.rb +1 -3
  9. data/lib/git/lint/analyzers/commit_author_name.rb +1 -3
  10. data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -6
  11. data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +3 -9
  12. data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +4 -12
  13. data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +3 -9
  14. data/lib/git/lint/analyzers/commit_body_line_length.rb +3 -9
  15. data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +3 -9
  16. data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -6
  17. data/lib/git/lint/analyzers/commit_body_presence.rb +2 -4
  18. data/lib/git/lint/analyzers/commit_body_single_bullet.rb +3 -9
  19. data/lib/git/lint/analyzers/commit_subject_length.rb +2 -6
  20. data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -10
  21. data/lib/git/lint/analyzers/commit_subject_suffix.rb +1 -3
  22. data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +1 -3
  23. data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +1 -3
  24. data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +1 -3
  25. data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +2 -6
  26. data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +2 -6
  27. data/lib/git/lint/branches/environments/circle_ci.rb +2 -6
  28. data/lib/git/lint/branches/environments/git_hub_action.rb +2 -6
  29. data/lib/git/lint/branches/environments/local.rb +2 -6
  30. data/lib/git/lint/branches/environments/netlify_ci.rb +1 -3
  31. data/lib/git/lint/branches/environments/travis_ci.rb +4 -12
  32. data/lib/git/lint/branches/feature.rb +1 -3
  33. data/lib/git/lint/collector.rb +10 -30
  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 +19 -5
  49. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 432f1e46b50a5ae86dc268318ea2a2cf720e68d57a00cbdc274d50379bbee24f
4
- data.tar.gz: 5ca784153ebd07153c70b4e7452a7ef0e141b32789e5d4f1c0fb95d861d698b2
3
+ metadata.gz: 9a9c8435e0b05c4beaf7129ff10a7e4e794374031fa1d1707234e27de5d3f815
4
+ data.tar.gz: fc01c78223f9fdbc1f458214d037e79d5c05245cfdcd2815e5c8d90583464322
5
5
  SHA512:
6
- metadata.gz: 9f53f339560363704e3f35560d3ee5dc6b43012c9eadbf088cd580ddbd0738f6933a16f963406eeb882d2f0d951b95894f7c25a581582c3058074879ab12e3ba
7
- data.tar.gz: b5cbe2dbe299a0f3690d64ceb6b2df00074d2112bdbb7bf93c031268705289db782118f19411f0083b592407fc071c84a5311deab01d6afd13e17592a03cb4de
6
+ metadata.gz: 3dac7a51483e7f92f72616226350611316aa0d2e2b9669080ebbfc5aba76b4df432b316d1a4e7e4a17f308dbe3b24d4891f81656c6c0189153ad1d6b9fed098f
7
+ data.tar.gz: 03e9445f0624f688b7bbb1cf11987cc56c31ebb52878a459b4ec26b6d9dd2994624b3602323e1ad8b3fb551803a2f9fd187214430a1831c93590391ec4a63108
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -760,8 +760,8 @@ added benefit of categorizing the commits for building release notes, change log
760
760
  handy when coupled with another tool, link:https://www.alchemists.io/projects/milestoner[Milestoner],
761
761
  for producing consistent project milestones and Git tag histories.
762
762
 
763
- Automatically ignores _fixup!_ or _squash!_ commit prefixes when used as a Git Hook in order to not
764
- disturb interactive rebase workflows.
763
+ 💡 Automatically ignores _amend!_, _fixup!_, or _squash!_ commit prefixes when used as a Git Hook in
764
+ order to not disturb interactive rebase workflows.
765
765
 
766
766
  === Commit Subject Suffix
767
767
 
data/lib/git/lint.rb CHANGED
@@ -1,50 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "zeitwerk"
3
4
  require "git_plus"
4
- require "git/lint/identity"
5
- require "git/lint/refinements/strings"
6
- require "git/lint/errors/base"
7
- require "git/lint/errors/severity"
8
- require "git/lint/errors/sha"
9
- require "git/lint/kit/filter_list"
10
- require "git/lint/validators/email"
11
- require "git/lint/validators/name"
12
- require "git/lint/validators/capitalization"
13
- require "git/lint/parsers/trailers/collaborator"
14
- require "git/lint/branches/environments/local"
15
- require "git/lint/branches/environments/circle_ci"
16
- require "git/lint/branches/environments/git_hub_action"
17
- require "git/lint/branches/environments/netlify_ci"
18
- require "git/lint/branches/environments/travis_ci"
19
- require "git/lint/branches/feature"
20
- require "git/lint/analyzers/abstract"
21
- require "git/lint/analyzers/commit_author_capitalization"
22
- require "git/lint/analyzers/commit_author_email"
23
- require "git/lint/analyzers/commit_author_name"
24
- require "git/lint/analyzers/commit_body_bullet"
25
- require "git/lint/analyzers/commit_body_bullet_capitalization"
26
- require "git/lint/analyzers/commit_body_bullet_delimiter"
27
- require "git/lint/analyzers/commit_body_issue_tracker_link"
28
- require "git/lint/analyzers/commit_body_leading_line"
29
- require "git/lint/analyzers/commit_body_line_length"
30
- require "git/lint/analyzers/commit_body_paragraph_capitalization"
31
- require "git/lint/analyzers/commit_body_phrase"
32
- require "git/lint/analyzers/commit_body_presence"
33
- require "git/lint/analyzers/commit_body_single_bullet"
34
- require "git/lint/analyzers/commit_subject_length"
35
- require "git/lint/analyzers/commit_subject_prefix"
36
- require "git/lint/analyzers/commit_subject_suffix"
37
- require "git/lint/analyzers/commit_trailer_collaborator_capitalization"
38
- require "git/lint/analyzers/commit_trailer_collaborator_duplication"
39
- require "git/lint/analyzers/commit_trailer_collaborator_email"
40
- require "git/lint/analyzers/commit_trailer_collaborator_key"
41
- require "git/lint/analyzers/commit_trailer_collaborator_name"
42
- require "git/lint/collector"
43
- require "git/lint/reporters/lines/sentence"
44
- require "git/lint/reporters/lines/paragraph"
45
- require "git/lint/reporters/line"
46
- require "git/lint/reporters/style"
47
- require "git/lint/reporters/commit"
48
- require "git/lint/reporters/branch"
49
- require "git/lint/runner"
50
- require "git/lint/cli"
5
+
6
+ loader = Zeitwerk::Loader.new
7
+ loader.inflector.inflect "cli" => "CLI",
8
+ "sha" => "SHA",
9
+ "circle_ci" => "CircleCI",
10
+ "netlify_ci" => "NetlifyCI",
11
+ "travis_ci" => "TravisCI"
12
+ loader.push_dir "#{__dir__}/.."
13
+ loader.ignore "#{__dir__}/lint/rake/setup.rb"
14
+ loader.setup
15
+
16
+ # Main namespace.
17
+ module Git
18
+ module Lint
19
+ end
20
+ end
@@ -18,25 +18,17 @@ module Git
18
18
  @descendants << klass unless klass.to_s.start_with? "#<Class" # Ignore anonymous classes.
19
19
  end
20
20
 
21
- def self.id
22
- to_s.delete_prefix("Git::Lint::Analyzers").snakecase.to_sym
23
- end
21
+ def self.id = to_s.delete_prefix("Git::Lint::Analyzers").snakecase.to_sym
24
22
 
25
- def self.label
26
- to_s.delete_prefix("Git::Lint::Analyzers").titleize
27
- end
23
+ def self.label = to_s.delete_prefix("Git::Lint::Analyzers").titleize
28
24
 
29
25
  def self.defaults
30
26
  fail NotImplementedError, "The `.#{__method__}` method must be implemented."
31
27
  end
32
28
 
33
- def self.descendants
34
- @descendants || []
35
- end
29
+ def self.descendants = @descendants || []
36
30
 
37
- def self.build_issue_line index, line
38
- {number: index + ISSUE_LINE_OFFSET, content: line}
39
- end
31
+ def self.build_issue_line(index, line) = {number: index + ISSUE_LINE_OFFSET, content: line}
40
32
 
41
33
  attr_reader :commit
42
34
 
@@ -46,9 +38,7 @@ module Git
46
38
  @filter_list = load_filter_list
47
39
  end
48
40
 
49
- def enabled?
50
- settings.fetch :enabled
51
- end
41
+ def enabled? = settings.fetch(:enabled)
52
42
 
53
43
  def severity
54
44
  settings.fetch(:severity).tap do |level|
@@ -60,17 +50,11 @@ module Git
60
50
  fail NotImplementedError, "The `##{__method__}` method must be implemented."
61
51
  end
62
52
 
63
- def invalid?
64
- !valid?
65
- end
53
+ def invalid? = !valid?
66
54
 
67
- def warning?
68
- invalid? && severity == :warn
69
- end
55
+ def warning? = invalid? && severity == :warn
70
56
 
71
- def error?
72
- invalid? && severity == :error
73
- end
57
+ def error? = invalid? && severity == :error
74
58
 
75
59
  def issue
76
60
  fail NotImplementedError, "The `##{__method__}` method must be implemented."
@@ -80,9 +64,7 @@ module Git
80
64
 
81
65
  attr_reader :settings, :filter_list
82
66
 
83
- def load_filter_list
84
- Kit::FilterList.new settings[:list]
85
- end
67
+ def load_filter_list = Kit::FilterList.new(settings[:list])
86
68
 
87
69
  def affected_commit_body_lines
88
70
  commit.body_lines.each.with_object([]).with_index do |(line, lines), index|
@@ -16,9 +16,7 @@ module Git
16
16
  @validator = validator
17
17
  end
18
18
 
19
- def valid?
20
- validator.new(commit.author_name).valid?
21
- end
19
+ def valid? = validator.new(commit.author_name).valid?
22
20
 
23
21
  def issue
24
22
  return {} if valid?
@@ -16,9 +16,7 @@ module Git
16
16
  @validator = validator
17
17
  end
18
18
 
19
- def valid?
20
- validator.new(commit.author_email).valid?
21
- end
19
+ def valid? = validator.new(commit.author_email).valid?
22
20
 
23
21
  def issue
24
22
  return {} if valid?
@@ -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?
@@ -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,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/#{repository.branch_default}..#{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/#{repository.branch_default}..#{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 "#{repository.branch_default}..#{name}"
19
- end
15
+ def commits = repository.commits("#{repository.branch_default}..#{name}")
20
16
 
21
17
  private
22
18
 
@@ -14,9 +14,7 @@ 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"]}"
@@ -14,9 +14,7 @@ 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
@@ -39,17 +37,11 @@ module Git
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
@@ -16,45 +16,25 @@ module Git
16
16
  analyzer
17
17
  end
18
18
 
19
- def retrieve id
20
- collection[id]
21
- end
19
+ def retrieve(id) = collection[id]
22
20
 
23
- def empty?
24
- collection.empty?
25
- end
21
+ def empty? = collection.empty?
26
22
 
27
- def warnings?
28
- collection.values.flatten.any?(&:warning?)
29
- end
23
+ def warnings? = collection.values.flatten.any?(&:warning?)
30
24
 
31
- def errors?
32
- collection.values.flatten.any?(&:error?)
33
- end
25
+ def errors? = collection.values.flatten.any?(&:error?)
34
26
 
35
- def issues?
36
- collection.values.flatten.any?(&:invalid?)
37
- end
27
+ def issues? = collection.values.flatten.any?(&:invalid?)
38
28
 
39
- def total_warnings
40
- collection.values.flatten.count(&:warning?)
41
- end
29
+ def total_warnings = collection.values.flatten.count(&:warning?)
42
30
 
43
- def total_errors
44
- collection.values.flatten.count(&:error?)
45
- end
31
+ def total_errors = collection.values.flatten.count(&:error?)
46
32
 
47
- def total_issues
48
- collection.values.flatten.count(&:invalid?)
49
- end
33
+ def total_issues = collection.values.flatten.count(&:invalid?)
50
34
 
51
- def total_commits
52
- collection.keys.size
53
- end
35
+ def total_commits = collection.keys.size
54
36
 
55
- def to_h
56
- collection
57
- end
37
+ def to_h = collection
58
38
 
59
39
  private
60
40
 
@@ -6,7 +6,7 @@ module Git
6
6
  module Identity
7
7
  NAME = "git-lint"
8
8
  LABEL = "Git Lint"
9
- VERSION = "2.2.1"
9
+ VERSION = "2.3.0"
10
10
  VERSION_LABEL = "#{LABEL} #{VERSION}"
11
11
  end
12
12
  end
@@ -9,17 +9,11 @@ module Git
9
9
  @list = Array list
10
10
  end
11
11
 
12
- def to_hint
13
- to_regexp.map(&:inspect).join ", "
14
- end
12
+ def to_hint = to_regexp.map(&:inspect).join(", ")
15
13
 
16
- def to_regexp
17
- list.map { |item| Regexp.new item }
18
- end
14
+ def to_regexp = list.map { |item| Regexp.new item }
19
15
 
20
- def empty?
21
- list.empty?
22
- end
16
+ def empty? = list.empty?
23
17
 
24
18
  private
25
19
 
@@ -27,21 +27,13 @@ module Git
27
27
  @matches = build_matches
28
28
  end
29
29
 
30
- def key
31
- String matches["key"]
32
- end
30
+ def key = String(matches["key"])
33
31
 
34
- def name
35
- String matches["name"]
36
- end
32
+ def name = String(matches["name"])
37
33
 
38
- def email
39
- String(matches["email"]).delete_prefix("<").delete_suffix(">")
40
- end
34
+ def email = String(matches["email"]).delete_prefix("<").delete_suffix(">")
41
35
 
42
- def match?
43
- text.match? key_pattern
44
- end
36
+ def match? = text.match?(key_pattern)
45
37
 
46
38
  private
47
39
 
@@ -9,9 +9,7 @@ module Git
9
9
  class Tasks
10
10
  include ::Rake::DSL
11
11
 
12
- def self.setup
13
- new.install
14
- end
12
+ def self.setup = new.install
15
13
 
16
14
  def initialize cli: CLI
17
15
  @cli = cli
@@ -11,13 +11,9 @@ module Git
11
11
  "#{count} #{self}#{suffix}"
12
12
  end
13
13
 
14
- def fixup?
15
- match?(/\Afixup!\s/)
16
- end
14
+ def fixup? = match?(/\Afixup!\s/)
17
15
 
18
- def squash?
19
- match?(/\Asquash!\s/)
20
- end
16
+ def squash? = match?(/\Asquash!\s/)
21
17
  end
22
18
  end
23
19
  end
@@ -7,7 +7,7 @@ module Git
7
7
  module Reporters
8
8
  # Reports issues related to a single branch.
9
9
  class Branch
10
- using Refinements::Strings
10
+ using GitPlus::Refinements::Strings
11
11
 
12
12
  def initialize collector: Collector.new, colorizer: Pastel.new
13
13
  @collector = collector
@@ -21,9 +21,7 @@ module Git
21
21
 
22
22
  attr_reader :commit, :analyzers
23
23
 
24
- def report
25
- analyzers.reduce("") { |report, analyzer| report + Style.new(analyzer).to_s }
26
- end
24
+ def report = analyzers.reduce("") { |report, analyzer| report + Style.new(analyzer).to_s }
27
25
  end
28
26
  end
29
27
  end
@@ -23,9 +23,7 @@ module Git
23
23
 
24
24
  attr_reader :data
25
25
 
26
- def content
27
- data.fetch :content
28
- end
26
+ def content = data.fetch(__method__)
29
27
  end
30
28
  end
31
29
  end
@@ -17,13 +17,9 @@ module Git
17
17
 
18
18
  attr_reader :data
19
19
 
20
- def label
21
- "#{Line::DEFAULT_INDENT}Line #{number}: "
22
- end
20
+ def label = "#{Line::DEFAULT_INDENT}Line #{number}: "
23
21
 
24
- def paragraph
25
- formatted_lines.join "\n"
26
- end
22
+ def paragraph = formatted_lines.join("\n")
27
23
 
28
24
  def formatted_lines
29
25
  content.split("\n").map.with_index do |line, index|
@@ -31,17 +27,11 @@ module Git
31
27
  end
32
28
  end
33
29
 
34
- def indent
35
- " " * (label.length + 1)
36
- end
30
+ def indent = " " * (label.length + 1)
37
31
 
38
- def number
39
- data.fetch :number
40
- end
32
+ def number = data.fetch(:number)
41
33
 
42
- def content
43
- data.fetch :content
44
- end
34
+ def content = data.fetch(:content)
45
35
  end
46
36
  end
47
37
  end
@@ -9,21 +9,15 @@ module Git
9
9
  @data = data
10
10
  end
11
11
 
12
- def to_s
13
- %(#{Line::DEFAULT_INDENT}Line #{number}: "#{content}"\n)
14
- end
12
+ def to_s = %(#{Line::DEFAULT_INDENT}Line #{number}: "#{content}"\n)
15
13
 
16
14
  private
17
15
 
18
16
  attr_reader :data
19
17
 
20
- def number
21
- data.fetch :number
22
- end
18
+ def number = data.fetch(:number)
23
19
 
24
- def content
25
- data.fetch :content
26
- end
20
+ def content = data.fetch(:content)
27
21
  end
28
22
  end
29
23
  end
@@ -13,9 +13,7 @@ module Git
13
13
  @colorizer = colorizer
14
14
  end
15
15
 
16
- def to_s
17
- colorizer.public_send color, message
18
- end
16
+ def to_s = colorizer.public_send(color, message)
19
17
 
20
18
  private
21
19
 
@@ -12,17 +12,13 @@ module Git
12
12
  @pattern = pattern
13
13
  end
14
14
 
15
- def valid?
16
- parts.all? { |name| String(name).match? pattern }
17
- end
15
+ def valid? = parts.all? { |name| String(name).match? pattern }
18
16
 
19
17
  private
20
18
 
21
19
  attr_reader :text, :delimiter, :pattern
22
20
 
23
- def parts
24
- text.split delimiter
25
- end
21
+ def parts = text.split(delimiter)
26
22
  end
27
23
  end
28
24
  end
@@ -11,9 +11,7 @@ module Git
11
11
  @pattern = pattern
12
12
  end
13
13
 
14
- def valid?
15
- String(text).match? pattern
16
- end
14
+ def valid? = String(text).match?(pattern)
17
15
 
18
16
  private
19
17
 
@@ -13,17 +13,13 @@ module Git
13
13
  @minimum = minimum
14
14
  end
15
15
 
16
- def valid?
17
- parts.size >= minimum && parts.all? { |name| !String(name).empty? }
18
- end
16
+ def valid? = parts.size >= minimum && parts.all? { |name| !String(name).empty? }
19
17
 
20
18
  private
21
19
 
22
20
  attr_reader :text, :delimiter, :minimum
23
21
 
24
- def parts
25
- String(text).split delimiter
26
- end
22
+ def parts = String(text).split(delimiter)
27
23
  end
28
24
  end
29
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
29
29
  W2A=
30
30
  -----END CERTIFICATE-----
31
- date: 2021-06-04 00:00:00.000000000 Z
31
+ date: 2021-07-05 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: git_plus
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.4'
39
+ version: '0.5'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.4'
46
+ version: '0.5'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: pastel
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0.20'
103
+ - !ruby/object:Gem::Dependency
104
+ name: zeitwerk
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '2.4'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '2.4'
103
117
  description:
104
118
  email:
105
119
  - brooke@alchemists.io
@@ -186,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
200
  - !ruby/object:Gem::Version
187
201
  version: '0'
188
202
  requirements: []
189
- rubygems_version: 3.2.19
203
+ rubygems_version: 3.2.21
190
204
  signing_key:
191
205
  specification_version: 4
192
206
  summary: A command line interface for linting Git commits.
metadata.gz.sig CHANGED
Binary file