codeowners-checker 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9768a17e8e26a830efa9f9808aec4a6e2fad800b1da0e7223fa68b8ee1a4c31c
4
+ data.tar.gz: 0e744a329069f56f24a1ba922c1c614eef6667816de05d6b042f2c77a883b559
5
+ SHA512:
6
+ metadata.gz: 02bcb19b84e96d42aedb93253baaedc4ead716c259dfc811f76d2bc75285c5a97ce69cffd4d88f82a9b5fa2891409337158fc0ba7fbef7090a55eaf9d722f41b
7
+ data.tar.gz: 2d63073791a7fa205e3aee026158fd37841217316c0a6bbbdad5c75f0ac73d9d9f3ab6858296c918cfc167654ca2d3778db4dc29822b1dbc98f16ebe21ea4c33
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /*.gem
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.projections.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "README.md": { "type": "readme" },
3
+ "lib/*.rb": { "type": "lib", "alternate": "spec/{}_spec.rb" }
4
+ }
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,28 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.5
5
+
6
+ Metrics/BlockLength:
7
+ Enabled: false
8
+
9
+ Metrics/LineLength:
10
+ Max: 120
11
+
12
+ Style/StructInheritance:
13
+ Enabled: false
14
+
15
+ RSpec/MultipleExpectations:
16
+ Enabled: false
17
+
18
+ RSpec/NamedSubject:
19
+ Enabled: false
20
+
21
+ RSpec/ExampleLength:
22
+ Enabled: false
23
+
24
+ RSpec/MessageSpies:
25
+ Enabled: false
26
+
27
+ RSpec/SubjectStub:
28
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jonatas.paganini@toptal.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # frozen_string_literal: true
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ codeowners-checker (1.0.0)
5
+ fuzzy_match (~> 2.1)
6
+ git (~> 1.5)
7
+ thor (~> 0.20.3)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.0)
13
+ coderay (1.1.2)
14
+ diff-lcs (1.3)
15
+ docile (1.3.0)
16
+ fuzzy_match (2.1.0)
17
+ git (1.5.0)
18
+ jaro_winkler (1.5.1)
19
+ json (2.1.0)
20
+ method_source (0.9.2)
21
+ parallel (1.12.1)
22
+ parser (2.5.3.0)
23
+ ast (~> 2.4.0)
24
+ powerpack (0.1.2)
25
+ pry (0.12.2)
26
+ coderay (~> 1.1.0)
27
+ method_source (~> 0.9.0)
28
+ rainbow (3.0.0)
29
+ rake (10.5.0)
30
+ rb-readline (0.5.5)
31
+ rspec (3.8.0)
32
+ rspec-core (~> 3.8.0)
33
+ rspec-expectations (~> 3.8.0)
34
+ rspec-mocks (~> 3.8.0)
35
+ rspec-core (3.8.0)
36
+ rspec-support (~> 3.8.0)
37
+ rspec-expectations (3.8.2)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.8.0)
40
+ rspec-mocks (3.8.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.8.0)
43
+ rspec-support (3.8.0)
44
+ rubocop (0.61.1)
45
+ jaro_winkler (~> 1.5.1)
46
+ parallel (~> 1.10)
47
+ parser (>= 2.5, != 2.5.1.1)
48
+ powerpack (~> 0.1)
49
+ rainbow (>= 2.2.2, < 4.0)
50
+ ruby-progressbar (~> 1.7)
51
+ unicode-display_width (~> 1.4.0)
52
+ rubocop-rspec (1.30.1)
53
+ rubocop (>= 0.60.0)
54
+ ruby-progressbar (1.10.0)
55
+ simplecov (0.16.1)
56
+ docile (~> 1.1)
57
+ json (>= 1.8, < 3)
58
+ simplecov-html (~> 0.10.0)
59
+ simplecov-html (0.10.2)
60
+ thor (0.20.3)
61
+ unicode-display_width (1.4.0)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ bundler (~> 1.16)
68
+ codeowners-checker!
69
+ pry (~> 0.12.2)
70
+ rake (~> 10.0)
71
+ rb-readline (~> 0.5.5)
72
+ rspec (~> 3.0)
73
+ rubocop (~> 0.61.1)
74
+ rubocop-rspec (~> 1.30)
75
+ simplecov (~> 0.16.1)
76
+
77
+ BUNDLED WITH
78
+ 1.17.3
data/Guardfile ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ guard 'livereload' do
21
+ watch(%r{lib/.+\.rb$})
22
+ end
23
+
24
+ guard :rspec, cmd: 'bundle exec rspec' do
25
+ require 'guard/rspec/dsl'
26
+ dsl = Guard::RSpec::Dsl.new(self)
27
+
28
+ # Feel free to open issues for suggestions and improvements
29
+
30
+ # RSpec files
31
+ rspec = dsl.rspec
32
+ watch(rspec.spec_helper) { rspec.spec_dir }
33
+ watch(rspec.spec_support) { rspec.spec_dir }
34
+ watch(rspec.spec_files)
35
+
36
+ # Ruby files
37
+ ruby = dsl.ruby
38
+ dsl.watch_spec_files_for(ruby.lib_files)
39
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jônatas Davi Paganini
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # Codeowners Checker
2
+
3
+ This gem checks if the GitHub codeowners are specified to all files changes
4
+ between two git revisions.
5
+
6
+ ## Installation
7
+
8
+ $ gem install codeowners-checker
9
+
10
+ ## Usage
11
+
12
+
13
+ ### Configure
14
+
15
+ $ codeowners-checker config owner <@owner>
16
+
17
+ It will configure `@owner` as the default owner in the config file.
18
+
19
+ ### Check file consistency
20
+
21
+ To check if your CODEOWNERS file is consistent with your current project you can run
22
+ this check.
23
+
24
+ $ codeowners-checker check
25
+
26
+ Or via code:
27
+
28
+ ```ruby
29
+ Codeowners::Checker.check! 'repo-dir', 'HEAD', 'branch-name'
30
+ ```
31
+
32
+
33
+ #### Example
34
+
35
+ Example CODEOWNERS file:
36
+
37
+ ```
38
+ # Backend
39
+ app/jobs/* @company/backend-devs
40
+ app/models/* @company/backend-devs
41
+
42
+ # Frontend
43
+ app/assets/* @company/frontend-devs
44
+ app/views/* @company/frontend-devs
45
+
46
+ # Shared
47
+ Gemfile @company
48
+ ```
49
+
50
+ The content of the CODEOWNERS file is parsed into groups where each group is a collection of patterns
51
+ separated by an empty line and comments describing the group. If no comment is present after
52
+ an empty line, a new group is created only in the case when the owner differs from the owner
53
+ of the previous group. It is also possible to define a group by comments `# BEGIN` and `# END`.
54
+ `# Group` can contain subgroups distinguished by the number of hashes: `## Subgroup`.
55
+
56
+ When a new file is added to the folder structure, the program detects the file and suggests possible
57
+ groups to which particular file belongs based on the main owner of the patterns in each group.
58
+ After selecting a group the pattern is added to the group in alphabetical order. If no group is
59
+ selected or found the pattern can be added at the end of the CODEOWNERS file.
60
+
61
+ After modifying the CODEOWNERS file the changes can be immediately committed.
62
+
63
+ ![Missing reference example](demos/missing_reference.svg)
64
+
65
+ Desired changes were made to the CODEOWNERS file:
66
+ ```
67
+ # Backend
68
+ app/controllers/application_controller.rb @company/backend-devs
69
+ app/jobs/* @company/backend-devs
70
+ app/models/* @company/backend-devs
71
+
72
+ # Frontend
73
+ app/assets/* @company/frontend-devs
74
+ app/views/* @company/frontend-devs
75
+
76
+ # Shared
77
+ Gemfile @company
78
+
79
+ lib/invoices.rb @company/billing-team
80
+ ```
81
+
82
+ Now some new patterns containing mistakes have been added by the user to the group `# Shared` and `# Billing`
83
+ and invalid pattern to a new group which is defined by `# BEGIN Security` and `# END Security` comments.
84
+
85
+ CODEOWNERS file after performing the changes described above:
86
+ ```
87
+ # Backend
88
+ app/controllers/application_controller.rb @company/backend-devs
89
+ app/jobs/* @company/backend-devs
90
+ app/models/* @company/backend-devs
91
+
92
+ # Frontend
93
+ app/assets/* @company/frontend-devs
94
+ app/views/* @company/frontend-devs
95
+
96
+ # Billing
97
+ app/models/billng.rb @company/billing-team
98
+ lib/invoices.rb @company/billing-team
99
+
100
+ # BEGIN Security
101
+ lib/security/* @company/security-team
102
+ # END Security
103
+
104
+ # Shared
105
+ .rubo.yml @company
106
+ Gemfile @company
107
+
108
+ ```
109
+
110
+ When running it again it will detect the invalid patterns. It will ask to fix the patterns
111
+ and suggest a possible alternative. The user can choose to accept the suggestion, ignore, edit
112
+ or delete the pattern. If the user decides to delete the last pattern in a group,
113
+ the comments defining the group are deleted as well as the pattern.
114
+
115
+ ![Useless pattern example](demos/useless_pattern.svg)
116
+
117
+ Invalid patterns were fixed and the group `Security` was removed when deleting the only pattern
118
+ in the group:
119
+ ```
120
+ # Backend
121
+ app/controllers/application_controller.rb @company/backend-devs
122
+ app/jobs/* @company/backend-devs
123
+ app/models/* @company/backend-devs
124
+
125
+ # Frontend
126
+ app/assets/* @company/frontend-devs
127
+ app/views/* @company/frontend-devs
128
+
129
+ # Billing
130
+ app/models/billing.rb @company/billing-team
131
+ lib/invoices.rb @company/billing-team
132
+
133
+ # Shared
134
+ .rubocop.yml @company
135
+ Gemfile @company
136
+ ```
137
+
138
+ ### Filtering Changes in Pull Requests
139
+
140
+ If you have a Pull Request to review and you just want to check the changes that
141
+ are meaningful to you, you can also filter the changes.
142
+
143
+ To list all the changes grouped by an owner:
144
+
145
+ $ codeowners-checker filter all
146
+
147
+ It will use the default owner from the configuration if you omit parameters:
148
+
149
+ $ codeowners-checker filter
150
+
151
+ Or you can filter any owner as a parameter:
152
+
153
+ $ codeowners-checker filter by <owner>
154
+
155
+ ## Development
156
+
157
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
158
+
159
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
160
+
161
+ ## Contributing
162
+
163
+ Bug reports and pull requests are welcome on GitHub at https://github.com/toptal/codeowners-checker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
164
+
165
+ ## License
166
+
167
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
168
+
169
+ ## Code of Conduct
170
+
171
+ Everyone interacting in the Codeowners::Checker project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/toptal/codeowners-checker/blob/master/CODE_OF_CONDUCT.md).