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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a9c8435e0b05c4beaf7129ff10a7e4e794374031fa1d1707234e27de5d3f815
|
4
|
+
data.tar.gz: fc01c78223f9fdbc1f458214d037e79d5c05245cfdcd2815e5c8d90583464322
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -14,27 +14,23 @@ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchem
|
|
14
14
|
image::https://circleci.com/gh/bkuhlmann/git-lint.svg?style=svg[Circle CI Status]
|
15
15
|
|
16
16
|
[link=https://travis-ci.org/bkuhlmann/git-lint]
|
17
|
-
image::https://travis-ci.org/bkuhlmann/git-lint.svg?branch=
|
17
|
+
image::https://travis-ci.org/bkuhlmann/git-lint.svg?branch=main[Travis CI Status]
|
18
18
|
[link=https://app.netlify.com/sites/git-lint/deploys]
|
19
19
|
image::https://api.netlify.com/api/v1/badges/7e23b422-3412-4e7f-b654-65c0417a0b1f/deploy-status[Netlify CI Status]
|
20
20
|
|
21
21
|
A command line interface for linting Git commits. Ensures you maintain a clean, easy to read,
|
22
22
|
debuggable, and maintainable project history.
|
23
23
|
|
24
|
-
*Git Lint is the official port of the original Git Cop project that avoids references to violence or
|
25
|
-
violent terminology that might make anyone feel unwelcome. The name change was necessary in order to
|
26
|
-
better support the link:https://blacklivesmatter.com[Black Lives Matter] and
|
27
|
-
link:https://8cantwait.org[Defund Police] movements.*
|
28
|
-
|
29
24
|
toc::[]
|
30
25
|
|
31
26
|
== Features
|
32
27
|
|
33
28
|
* Enforces a {git_rebase_workflow_link}.
|
34
29
|
* Enforces a clean and consistent Git commit history.
|
30
|
+
* Supports Git default branch configuration.
|
35
31
|
* Provides a customizable suite of analyzers.
|
36
32
|
* Provides Git Hook support for local use.
|
37
|
-
* Provides Continuous Integration (CI)
|
33
|
+
* Provides Continuous Integration (CI) support.
|
38
34
|
|
39
35
|
== Screencasts
|
40
36
|
|
@@ -71,9 +67,9 @@ git-lint -v, [--version] # Show gem version.
|
|
71
67
|
To check if your Git commit history is clean, run: `git-lint --analyze`. It will exit with a failure
|
72
68
|
if at least one issue with error severity is detected.
|
73
69
|
|
74
|
-
This gem does not check commits on `
|
75
|
-
to rewrite or fix commits on `
|
76
|
-
detects all commits made since
|
70
|
+
This gem does not check commits on your default branch (i.e. `main`). This is intentional as you
|
71
|
+
would, generally, not want to rewrite or fix commits on the `main` branch. This gem is best used on
|
72
|
+
feature branches as it automatically detects all commits made since creation of the feature branch.
|
77
73
|
|
78
74
|
Here is an example workflow, using gem defaults with issues detected:
|
79
75
|
|
@@ -115,6 +111,21 @@ Now, when running `bundle exec rake -T`, you'll see `git_lint` included in the l
|
|
115
111
|
|
116
112
|
If you need a concrete example, check out the link:Rakefile[Rakefile] of this project for details.
|
117
113
|
|
114
|
+
=== Default Branch
|
115
|
+
|
116
|
+
Your default branch configuration is respected no matter if it is set globally or locally. If the
|
117
|
+
default branch is _not set_ then Git Lint will fall back to `master` for backwards compatibility.
|
118
|
+
When the next major version is released, the default branch fallback will change from `master` to
|
119
|
+
`main`. You can set your default branch at any time by running the following from the command line:
|
120
|
+
|
121
|
+
[source,bash]
|
122
|
+
----
|
123
|
+
git config --add init.defaultBranch main
|
124
|
+
----
|
125
|
+
|
126
|
+
💡 When setting your default branch, ensure you use a consistent Git configuration across all of
|
127
|
+
your environments.
|
128
|
+
|
118
129
|
=== Configuration
|
119
130
|
|
120
131
|
This gem can be configured via a global configuration:
|
@@ -293,7 +304,7 @@ maintenance costs for you. To configure global Git Hooks, add the following to y
|
|
293
304
|
....
|
294
305
|
|
295
306
|
Then you can customize Git Hooks for all of your projects.
|
296
|
-
link:https://github.com/bkuhlmann/dotfiles/tree/
|
307
|
+
link:https://github.com/bkuhlmann/dotfiles/tree/main/home_files/.config/git/hooks[Check out these
|
297
308
|
examples].
|
298
309
|
|
299
310
|
If a global configuration is not desired, you can add Git Hooks at a per project level by editing
|
@@ -378,7 +389,7 @@ have a build server that is not listed, please log an issue or provide an implem
|
|
378
389
|
support.
|
379
390
|
|
380
391
|
Calculation of commits is done by reviewing all commits made on the feature branch since branching
|
381
|
-
from `
|
392
|
+
from `main`.
|
382
393
|
|
383
394
|
==== link:https://circleci.com[Circle CI]
|
384
395
|
|
@@ -736,9 +747,12 @@ Ensures the commit subject uses consistent prefixes that explain _what_ is being
|
|
736
747
|
* *Updated* - Identifies what was updated. The commit should be as small as possible and _not add
|
737
748
|
or fix_ existing behavior. This can sometimes be a grey area but is typically reserved for updates
|
738
749
|
to documentation, code comments, dependencies, etc.
|
739
|
-
* *Refactored* - Identifies what was refactored.
|
740
|
-
|
741
|
-
|
750
|
+
* *Refactored* - Identifies what was refactored.
|
751
|
+
link:https://thoughtbot.com/blog/lets-not-misuse-refactoring[_Refactoring is for changing code
|
752
|
+
structure without changing observable behavior_]. The commit should be as small as possible and
|
753
|
+
not mix multiple kinds of changes at once. Refactored code should never break existing
|
754
|
+
implementation behavior or corresponding specs because, if that happens, then one of the other
|
755
|
+
four prefixes is what you want to use instead.
|
742
756
|
|
743
757
|
In practice, using a prefix other than what has been detailed above to explain _what_ is being
|
744
758
|
committed is never needed. These prefixes are not only short and easy to remember but also have the
|
@@ -746,8 +760,8 @@ added benefit of categorizing the commits for building release notes, change log
|
|
746
760
|
handy when coupled with another tool, link:https://www.alchemists.io/projects/milestoner[Milestoner],
|
747
761
|
for producing consistent project milestones and Git tag histories.
|
748
762
|
|
749
|
-
Automatically ignores _fixup!_ or _squash!_ commit prefixes when used as a Git Hook in
|
750
|
-
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.
|
751
765
|
|
752
766
|
=== Commit Subject Suffix
|
753
767
|
|
@@ -870,7 +884,7 @@ worth considering:
|
|
870
884
|
blindly combine multiple commit messages without editing them into a single, coherent message._
|
871
885
|
* Use `git rebase --interactive` when cleaning up commit history, order, messages, etc. This should
|
872
886
|
be done prior to submitting a code review or when code review feedback has been addressed and
|
873
|
-
you are ready to rebase onto `
|
887
|
+
you are ready to rebase onto `main`.
|
874
888
|
* Use `git push --force-with-lease` instead of `git push --force` when pushing changes after an
|
875
889
|
interactive rebasing session.
|
876
890
|
* Avoid checking in development-specific configuration files (add to `.gitignore` instead).
|
@@ -932,11 +946,11 @@ configuration disabled.
|
|
932
946
|
=== Branches
|
933
947
|
|
934
948
|
* Use feature branches for new work.
|
935
|
-
* Maintain branches by rebasing upon `
|
949
|
+
* Maintain branches by rebasing upon `main` on a regular basis.
|
936
950
|
|
937
951
|
=== Tags
|
938
952
|
|
939
|
-
* Use tags to denote milestones/releases:
|
953
|
+
* Use tags to denote link:https://www.alchemists.io/projects/milestoner[milestones]/releases:
|
940
954
|
** Makes it easier to record milestones and capture associated release notes.
|
941
955
|
** Makes it easier to compare differences between versions.
|
942
956
|
** Provides a starting point for debugging production issues (if any).
|
@@ -954,131 +968,15 @@ configuration disabled.
|
|
954
968
|
* Use hooks globally rather than locally per project. Doing this applies the same functionality
|
955
969
|
across all projects automatically, reduces maintenance per project, and provides consistency
|
956
970
|
across all projects. This can best be managed via your
|
957
|
-
link:https://github.com/bkuhlmann/dotfiles/tree/
|
971
|
+
link:https://github.com/bkuhlmann/dotfiles/tree/main/home_files/.config/git/hooks[Dotfiles].
|
958
972
|
* Avoid forcing global or local project hooks as a team-wide mandate. Hooks are a personal tool much
|
959
973
|
like editors or other tools one choose to do their work. For team consistency, use a continuous
|
960
974
|
integration build server instead.
|
961
975
|
|
962
976
|
=== Code Reviews
|
963
977
|
|
964
|
-
|
965
|
-
|
966
|
-
. *Joy* - The experience of working with you, receiving feedback, giving feedback, and demonstrating
|
967
|
-
a level of care influences others and encourages a collaborative environment that is fun to work
|
968
|
-
in. Use this time to build and reinforce trust amongst your fellow colleagues.
|
969
|
-
. *Quality*: Ensures changes are of highest quality that adhere to team standards while enhancing
|
970
|
-
the customer experience and not disrupting their workflow.
|
971
|
-
. *Education*: Provides a chance for everyone on the team to learn more about the architecture,
|
972
|
-
product/service, and how each member of the team implements a solution. This is your chance to
|
973
|
-
ask questions and learn how to be a better engineer so take advantage of it.
|
974
|
-
|
975
|
-
In addition to the objectives above, the following guidelines are worth following:
|
976
|
-
|
977
|
-
* Keep code reviews short and easy to review:
|
978
|
-
** Review your own code first before submitting to others. By ensuring your are confident in the
|
979
|
-
overall implementation and the commits in terms of commit messages and implementation details,
|
980
|
-
you'll encourage higher quality feedback and show appreciation for the reviewer's time.
|
981
|
-
** Provide a high level overview that answers _why_ the code review is necessary.
|
982
|
-
** Provide a link to the issue that prompted the code review (if any) and any additional details
|
983
|
-
worth highlighting to guide the reviewer through the process.
|
984
|
-
** Provide screenshots/screencasts if possible.
|
985
|
-
** Provide any ancillary notes or points of interest worth highlighting for the reviewer.
|
986
|
-
** Ensure commits within the code review are related to the purpose of the code review and avoid
|
987
|
-
mixing in changes that are ancillary to the primary objective of the code view. If you do have
|
988
|
-
changes outside of the scope of the current code review, open those changes up as a separate code
|
989
|
-
review instead.
|
990
|
-
** Prefer code reviews at about 300 lines in order to keep the quality of the code review and defect
|
991
|
-
detection high. This also shows you value the reviewers time and attention away from their own
|
992
|
-
work.
|
993
|
-
** Avoid working on a large issues without first getting feedback in order to not overwhelm/surprise
|
994
|
-
the maintainers. More discussion up front will help ensure your work has a faster chance of
|
995
|
-
acceptance.
|
996
|
-
* Review and rebase code reviews quickly:
|
997
|
-
** Maintain a consistent but reasonable pace -- Review morning, noon, and night.
|
998
|
-
** Avoid letting code reviews linger more than a day. Otherwise, you risk hampering moral and
|
999
|
-
diminishing the productivity of the team.
|
1000
|
-
* Use emojis, with a format of `<emoji> <feedback>`, to identify the kinds of feedback used during
|
1001
|
-
the review process:
|
1002
|
-
** 🍵 (`:tea:`) - Signifies you are starting the code review. This is _non-blocking_ and
|
1003
|
-
informational. Useful when reading over a code review with a large number of commits, complex
|
1004
|
-
code, requires additional testing by the reviewer, etc.
|
1005
|
-
** ⭐️ (`:star:`) - Signifies code that is liked, favorited, remarkable, etc. This feedback is
|
1006
|
-
_non-blocking_ and is always meant to be positive/uplifting.
|
1007
|
-
** ℹ️ (`:information_source:`) - Signifies informational feedback that is
|
1008
|
-
_non-blocking_. Can also be used to let one know you are done reviewing but haven't approved yet
|
1009
|
-
(due to feedback that needs addressing), rebasing a code review and then merging, waiting for a
|
1010
|
-
blocking code review to be resolved, status updates to the code review, etc.
|
1011
|
-
** 💭 (`:thought_balloon:`) - Signifies inquisitive intent that is _non-blocking_.
|
1012
|
-
Useful when asking questions and/or probing deeper into implementation details to learn more.
|
1013
|
-
** 🔤 (`:abc:`) - Signifies detection of a misspelling with suggested correction. This is
|
1014
|
-
_blocking_ feedback that is easy to correct.
|
1015
|
-
** 🎨 (`:art:`) - Signifies an issue with code style and/or code quality. This can be _blocking_
|
1016
|
-
or _non-blocking_ feedback. It is up to the discretion of the author on how to address the
|
1017
|
-
feedback but encouraged that the feedback is incorporated or at least discussed. Generally,
|
1018
|
-
these situations are automatically detected via code linters but there are occasions where
|
1019
|
-
there is ambiguity in which linters can't catch.
|
1020
|
-
** 🏛 (`:classical_building:`) - Signifies an issue with the architecture of the
|
1021
|
-
implementation. This is _blocking_ and requires immediate correction. The reviewer should
|
1022
|
-
provide a suggested solution and/or links to patterns, articles, etc. that might help the author
|
1023
|
-
fix the implementation. Pairing is encouraged if feedback is vast and/or complex.
|
1024
|
-
** 🔒 (`:lock:`) - Signifies a security violation that would damage us and/or our customers. This is
|
1025
|
-
_blocking_ feedback and must be addressed immediately.
|
1026
|
-
** 💡 (`:bulb:`) - Indicates a helpful tip or trick for improving the code. This can be
|
1027
|
-
_blocking_ or _non-blocking_ feedback and is left up to the author to decide. Generally, it is a
|
1028
|
-
good idea to address and resolve the feedback.
|
1029
|
-
** 🙇 (`:bow:`) - Indicates thankfulness of the feedback received. This is _non-blocking_ and
|
1030
|
-
always meant as a response to helpful feedback.
|
1031
|
-
** ✅ (`:white_check_mark:`) - Signifies code review approval. The author can
|
1032
|
-
rebase onto `master` and delete the feature branch at this point.
|
1033
|
-
* Use all feedback as a chance to learn, teach, strenghen the bond of trust between you and your
|
1034
|
-
fellow colleagues, and avoid being cut by
|
1035
|
-
link:https://fs.blog/2017/04/mental-model-hanlons-razor[Hanlon's Razor].
|
1036
|
-
* Use automation to ensure code reviews are consistent, of high quality, and swift to resolve. Each
|
1037
|
-
code review can be an opportunity to identify and automate the process further.
|
1038
|
-
* Use face-to-face communication if a code review's written discussion gets lengthy/noisy.
|
1039
|
-
* Create follow-up actions if additional features are discovered during a code review to avoid
|
1040
|
-
delaying code review acceptance. Return to the code review once the new actions have been logged.
|
1041
|
-
* The author, not the reviewer, should rebase the feature branch onto `master` upon approval.
|
1042
|
-
* Avoid reviewing your own code review before rebasing onto `master`. Have another pair of eyes
|
1043
|
-
review your code first.
|
1044
|
-
* Ensure the following criteria is met before rebasing your feature branch to `master`:
|
1045
|
-
** Ensure all `fixup!` and `squash!` commits are interactively rebased. _Avoid rebasing these onto
|
1046
|
-
the `master` branch!_
|
1047
|
-
** Ensure your feature branch is rebased upon `master`.
|
1048
|
-
** Ensure all tests and code quality checks are passing.
|
1049
|
-
** Ensure the feature branch is deleted after being successfully rebased.
|
1050
|
-
|
1051
|
-
=== GitHub
|
1052
|
-
|
1053
|
-
When using GitHub, enforce a rebase workflow for all of your GitHub projects (_highly recommended_).
|
1054
|
-
You can do this via your project options (i.e. `https://github.com/<username/<project>/settings`)
|
1055
|
-
and editing your merge options for code reviews as follows:
|
1056
|
-
|
1057
|
-
image::https://www.alchemists.io/images/projects/git-lint/screenshots/github-settings-options.png[GitHub Merge Options]
|
1058
|
-
|
1059
|
-
In addition to the above, you'll want to add _branch_ protection rules for your `master` branch. To
|
1060
|
-
do this, follow these steps:
|
1061
|
-
|
1062
|
-
. Visit your branch settings (i.e. `https://github.com/<username>/<project>/settings/branches`).
|
1063
|
-
. Click the _Add rule_ button.
|
1064
|
-
. For _branch name pattern_, enter: `master`.
|
1065
|
-
. Check _Require pull request reviews before merging_.
|
1066
|
-
. Set _Required approving reviews_ to `2` as a minimum.
|
1067
|
-
. Check _Dismiss stale pull request approvals when new commits are pushed_.
|
1068
|
-
. Check _Require review from Code Owners_.
|
1069
|
-
. Check _Require status checks to pass before merging_.
|
1070
|
-
. Check _Require branches to be up to date before merging_.
|
1071
|
-
. Check _Require signed commits_.
|
1072
|
-
. Check _Require linear history_ (pairs well with the merge options mentioned above).
|
1073
|
-
. Check _Include administrators_.
|
1074
|
-
. Uncheck _Allow force pushes_.
|
1075
|
-
. Uncheck _Allow deletions_.
|
1076
|
-
|
1077
|
-
With the above applied, you should have the following result:
|
1078
|
-
|
1079
|
-
image::https://www.alchemists.io/images/projects/git-lint/screenshots/github-settings-branch_protections.png[GitHub Branch Protections]
|
1080
|
-
|
1081
|
-
Applying the above changes will help maintain a clean Git history.
|
978
|
+
For an in depth look at how to conduct code reviews, please read my
|
979
|
+
link:https://www.alchemists.io/articles/code_reviews[article] on this subject to learn more.
|
1082
980
|
|
1083
981
|
== Development
|
1084
982
|
|
data/lib/git/lint.rb
CHANGED
@@ -1,52 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
require "git/lint/branches/feature"
|
22
|
-
require "git/lint/analyzers/abstract"
|
23
|
-
require "git/lint/analyzers/commit_author_capitalization"
|
24
|
-
require "git/lint/analyzers/commit_author_email"
|
25
|
-
require "git/lint/analyzers/commit_author_name"
|
26
|
-
require "git/lint/analyzers/commit_body_bullet"
|
27
|
-
require "git/lint/analyzers/commit_body_bullet_capitalization"
|
28
|
-
require "git/lint/analyzers/commit_body_bullet_delimiter"
|
29
|
-
require "git/lint/analyzers/commit_body_issue_tracker_link"
|
30
|
-
require "git/lint/analyzers/commit_body_leading_line"
|
31
|
-
require "git/lint/analyzers/commit_body_line_length"
|
32
|
-
require "git/lint/analyzers/commit_body_paragraph_capitalization"
|
33
|
-
require "git/lint/analyzers/commit_body_phrase"
|
34
|
-
require "git/lint/analyzers/commit_body_presence"
|
35
|
-
require "git/lint/analyzers/commit_body_single_bullet"
|
36
|
-
require "git/lint/analyzers/commit_subject_length"
|
37
|
-
require "git/lint/analyzers/commit_subject_prefix"
|
38
|
-
require "git/lint/analyzers/commit_subject_suffix"
|
39
|
-
require "git/lint/analyzers/commit_trailer_collaborator_capitalization"
|
40
|
-
require "git/lint/analyzers/commit_trailer_collaborator_duplication"
|
41
|
-
require "git/lint/analyzers/commit_trailer_collaborator_email"
|
42
|
-
require "git/lint/analyzers/commit_trailer_collaborator_key"
|
43
|
-
require "git/lint/analyzers/commit_trailer_collaborator_name"
|
44
|
-
require "git/lint/collector"
|
45
|
-
require "git/lint/reporters/lines/sentence"
|
46
|
-
require "git/lint/reporters/lines/paragraph"
|
47
|
-
require "git/lint/reporters/line"
|
48
|
-
require "git/lint/reporters/style"
|
49
|
-
require "git/lint/reporters/commit"
|
50
|
-
require "git/lint/reporters/branch"
|
51
|
-
require "git/lint/runner"
|
52
|
-
require "git/lint/cli"
|
3
|
+
require "zeitwerk"
|
4
|
+
require "git_plus"
|
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|
|
@@ -91,10 +73,10 @@ module Git
|
|
91
73
|
end
|
92
74
|
end
|
93
75
|
|
94
|
-
def
|
95
|
-
commit.
|
76
|
+
def affected_commit_trailers
|
77
|
+
commit.trailers
|
96
78
|
.each.with_object([])
|
97
|
-
.with_index(commit.
|
79
|
+
.with_index(commit.trailers_index) do |(line, lines), index|
|
98
80
|
yield if block_given?
|
99
81
|
lines << self.class.build_issue_line(index, line) if invalid_line? line
|
100
82
|
end
|