denmark 0.0.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.
- checksums.yaml +7 -0
- data/LICENSE +202 -0
- data/README.md +182 -0
- data/bin/denmark +66 -0
- data/lib/denmark/monkeypatches.rb +19 -0
- data/lib/denmark/plugins/issues.rb +46 -0
- data/lib/denmark/plugins/metadata.rb +84 -0
- data/lib/denmark/plugins/pull_requests.rb +46 -0
- data/lib/denmark/plugins.rb +40 -0
- data/lib/denmark/repository.rb +130 -0
- data/lib/denmark/version.rb +5 -0
- data/lib/denmark.rb +123 -0
- metadata +183 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6380ca654ddd088c98333d7138d04aaa373ca55c6b9daa36b444f7e4989789c5
|
|
4
|
+
data.tar.gz: df1b592c399613a81d12b5a6737d86dca9c4ac82cf51474fd6f39a3488996805
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a15992e3393807a833f289729d83abcb71cee333aebd06292fde936e82bcb7e52ff65e10522d3726864c024beada6de74509ffac1c0141e8aedb82c6769e07bc
|
|
7
|
+
data.tar.gz: f8f892945406e0b74a6d3b21c4ed004779a5278302e468271cd33c3167a1ab089a6eacd30a8524fe412bdf70f886a4da9d5dd7caf7ef48c96dd189f6de23f74f
|
data/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Denmark
|
|
2
|
+
|
|
3
|
+
> Something is rotten in the state of Denmark.<br />
|
|
4
|
+
> -- *Horatio* in Shakespeare's Hamlet
|
|
5
|
+
|
|
6
|
+
I'm sure you've had the experience of evaluating modules on the Puppet Forge. Maybe
|
|
7
|
+
you were comparing a handful that all claimed to meet your needs, or maybe you were
|
|
8
|
+
just determining whether a specific module met your standards for deploying into
|
|
9
|
+
your production environment.
|
|
10
|
+
|
|
11
|
+
How did you go about it? You probably
|
|
12
|
+
|
|
13
|
+
* Skimmed the module's README for signs of the author's diligence.
|
|
14
|
+
* Poked through the issue list and pull requests on the repository hosting the module
|
|
15
|
+
source to see how responsive the maintainers were to community collaboration.
|
|
16
|
+
* Checked the changelog for consistency.
|
|
17
|
+
* Maybe you even checked the commit history to see if there were unreleased fixes, or
|
|
18
|
+
compared tags against the published version(s).
|
|
19
|
+
|
|
20
|
+
Wouldn't it be nice to automate some of this due diligence? That's what `denmark` does.
|
|
21
|
+
The Shakespeare quote refers to corruption at the top of a political hierarchy making
|
|
22
|
+
its way down through the entire state. In the context of this tool, it means that often
|
|
23
|
+
we can detect concerns with a project by sniffing around the edges and seeing if anything
|
|
24
|
+
rolling downhill stinks.
|
|
25
|
+
|
|
26
|
+
⚠️⚠️⚠️ ***Warning:** This is a very early release. It will be some time before the smell checks
|
|
27
|
+
it does are actually representative of the things you should be concerned about.*
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Overview
|
|
31
|
+
|
|
32
|
+
Denmark takes the name of a module, then extracts information from the Forge and from
|
|
33
|
+
the repository server hosting the module's source. This means that it relies on the
|
|
34
|
+
module to have an accurate `source` or `project_page` key set in its `metadata.json`.
|
|
35
|
+
Denmark currently supports both GitHub and GitLab source repositories.
|
|
36
|
+
|
|
37
|
+
Running Denmark will generate a report on your terminal of things you should look into.
|
|
38
|
+
Of course, if you'd like to integrate it into other tooling, it's also got JSON output.
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
$ denmark smell binford2k-node_encrypt --detail
|
|
42
|
+
|
|
43
|
+
[RED] alerts:
|
|
44
|
+
The version released on the Forge does not match the version in the repository.
|
|
45
|
+
> Validate that the Forge release is not compromised and is the latest released version.
|
|
46
|
+
|
|
47
|
+
[YELLOW] alerts:
|
|
48
|
+
60% of the issues in this module's repository are more than 3 years old.
|
|
49
|
+
> Many very old issues may indicate that the maintainer is not responding to community feedback.
|
|
50
|
+
The version released on the Forge does not match the latest tag in the repo.
|
|
51
|
+
> This sometimes just indicates sloppy release practices, but could indicate a compromised Forge release.
|
|
52
|
+
The module was not published to the Forge on the same day that the latest release was tagged.
|
|
53
|
+
> This sometimes just indicates sloppy release practices, but could indicate a compromised Forge release.
|
|
54
|
+
|
|
55
|
+
[GREEN] alerts:
|
|
56
|
+
There was a gap of at least a year between the last two releases.
|
|
57
|
+
> A large gap between releases often shows sporadic maintenance. This is not always bad.
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
As you can see, I've got some sloppiness issues on my module that I should go clean up!
|
|
61
|
+
Turns out that I'd built and published the module locally, but forgot to push and tag my
|
|
62
|
+
changes.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
Denmark is shipped as a standard RubyGem.
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
$ gem install denmark
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## Configuration
|
|
75
|
+
|
|
76
|
+
GitHub allows anonymous rate-limited access to its API. If you're just evaluating a single
|
|
77
|
+
module, you can just use this tool, as long as the module source is on GitHub. If you're
|
|
78
|
+
evaluating many modules or any modules with their source on GitLab, you'll need tokens:
|
|
79
|
+
|
|
80
|
+
### `~/.config/denmark.yaml`
|
|
81
|
+
``` yaml
|
|
82
|
+
---
|
|
83
|
+
:gitlab:
|
|
84
|
+
:token: <token>
|
|
85
|
+
:github:
|
|
86
|
+
:token: <token>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
See these pages for instructions on generating tokens:
|
|
90
|
+
|
|
91
|
+
* [GitHub](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
|
|
92
|
+
* [GitLab](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## Contributing
|
|
96
|
+
|
|
97
|
+
Denmark keeps individual smell tests in plugin files in the `lib/denmark/plugins/` directory.
|
|
98
|
+
See the existing plugins for examples of the existing tests.
|
|
99
|
+
|
|
100
|
+
Start by copying the skeleton file below into a new plugin source file. This
|
|
101
|
+
should be a Ruby file that lives in `lib/denmark/plugins/` and defines a single
|
|
102
|
+
class named after its filename. For example, if you wanted to write a plugin to
|
|
103
|
+
analyze the readability of the README file, you might create the class
|
|
104
|
+
`Dropsonde::Metrics::Readme` in the Ruby file named `lib/denmark/plugins/readme.rb`.
|
|
105
|
+
|
|
106
|
+
Hooks are defined as a series of class methods and each of them is documented
|
|
107
|
+
below. Flesh each method out as needed.
|
|
108
|
+
|
|
109
|
+
``` ruby
|
|
110
|
+
class Denmark::Plugins::Demo
|
|
111
|
+
def self.description
|
|
112
|
+
# Return a string explaining what this smell test evaluates.
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def self.setup
|
|
116
|
+
# run just before generating this metric. Seldom used.
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
@param mod The Puppet module object returned from the Forge API
|
|
120
|
+
@param repo An object representing the git repository. See below for abstraction details
|
|
121
|
+
@returns Array[Hash] Test outputs to be merged into the combined report.
|
|
122
|
+
def self.run(mod, repo)
|
|
123
|
+
# return an array of hashes representing the data to be merged into the combined report.
|
|
124
|
+
# See below for the API.
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def self.cleanup
|
|
128
|
+
# run just after generating this metric. Seldom used.
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Plugin return value
|
|
135
|
+
|
|
136
|
+
Your plugin should return an array of hashes representing the smells discovered. You must
|
|
137
|
+
return an array, even if it's empty. It should look like so:
|
|
138
|
+
|
|
139
|
+
``` ruby
|
|
140
|
+
[
|
|
141
|
+
{
|
|
142
|
+
severity: :orange,
|
|
143
|
+
message: "The warning message.",
|
|
144
|
+
explanation: "A longform explanation of why this could be a problem. This is displayed when --detail is used.",
|
|
145
|
+
},
|
|
146
|
+
]
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Severity levels
|
|
150
|
+
|
|
151
|
+
* `:red`: The most severe level. This is almost certainly a problem and must be investigated.
|
|
152
|
+
* `:orage`
|
|
153
|
+
* `:yellow`
|
|
154
|
+
* `:green`: The least severe level. Mostly informational, but you should know about it.
|
|
155
|
+
|
|
156
|
+
#### Repository abstraction
|
|
157
|
+
|
|
158
|
+
The `Denmark::Repository` object is a _very_ thin wrapper around the GitHub and GitLab APIs.
|
|
159
|
+
It abstracts slight differences between the APIs and adds some helper methods to make it
|
|
160
|
+
simpler to do common things like load the contents of a file. See the source of
|
|
161
|
+
[lib/denmark/repository.rb](lib/denmark/repository.rb) for the methods it exposes.
|
|
162
|
+
|
|
163
|
+
We've also extended the `Array` class with a `.percent_of` method. This allows you to quickly
|
|
164
|
+
identify the percentage of items in an array that match a condition you specify in a block.
|
|
165
|
+
For example, this snippet returns the integer percentage of the issues on a repo with no comments:
|
|
166
|
+
|
|
167
|
+
``` ruby
|
|
168
|
+
unanswered = repo.issues.percent_of {|i| i.comments == 0 }
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## Limitations
|
|
173
|
+
|
|
174
|
+
This tool is extremely early in its development and the output API is not yet formally defined.
|
|
175
|
+
If you write tooling to use it, then make your tooling resilient to changes.
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
Contact
|
|
179
|
+
-------
|
|
180
|
+
|
|
181
|
+
community@puppet.com
|
|
182
|
+
|
data/bin/denmark
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'gli'
|
|
3
|
+
require 'denmark'
|
|
4
|
+
require 'denmark/version'
|
|
5
|
+
|
|
6
|
+
class Denmark
|
|
7
|
+
extend GLI::App
|
|
8
|
+
|
|
9
|
+
program_desc 'A simple tool for checking Puppet Forge modules for maintenance smells'
|
|
10
|
+
version Denmark::VERSION
|
|
11
|
+
|
|
12
|
+
pre do |global, command, options, args|
|
|
13
|
+
Denmark.config = YAML.load_file("#{Dir.home}/.config/denmark.yaml") rescue {}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc 'Verbose output'
|
|
17
|
+
switch [:verbose, :v]
|
|
18
|
+
|
|
19
|
+
desc 'List all available tests'
|
|
20
|
+
command :list do |c|
|
|
21
|
+
c.action do |global, options, args|
|
|
22
|
+
Denmark.list(options)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc 'Show info about a module'
|
|
27
|
+
command :info do |c|
|
|
28
|
+
c.action do |global, options, args|
|
|
29
|
+
Denmark.info args[0]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
desc 'Smell test a module using all enabled tests'
|
|
34
|
+
command :smell do |c|
|
|
35
|
+
c.desc 'Lists of tests to enable'
|
|
36
|
+
c.flag [:enable, :e], :type => Array
|
|
37
|
+
|
|
38
|
+
c.desc 'List of tests to omit'
|
|
39
|
+
c.flag [:disable, :d], :type => Array
|
|
40
|
+
|
|
41
|
+
c.desc 'The output format to use'
|
|
42
|
+
c.flag [:format], :default_value => 'human'
|
|
43
|
+
|
|
44
|
+
c.desc 'Include alert details'
|
|
45
|
+
c.switch [:detail, :D]
|
|
46
|
+
|
|
47
|
+
c.action do |global, options, args|
|
|
48
|
+
Denmark.evaluate(args.first, options)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
desc "Commands useful for developers"
|
|
53
|
+
command :dev do |t|
|
|
54
|
+
t.desc 'Open a Pry shell for debugging'
|
|
55
|
+
t.command :shell do |c|
|
|
56
|
+
c.action do |global, options, args|
|
|
57
|
+
require 'pry'
|
|
58
|
+
binding.pry
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
exit Denmark.run(ARGV)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Array
|
|
4
|
+
def percent_of(digits = nil)
|
|
5
|
+
raise "Select the items you want to count using a block that returns a boolean" unless block_given?
|
|
6
|
+
|
|
7
|
+
count = self.size
|
|
8
|
+
match = 0
|
|
9
|
+
self.each do |elem|
|
|
10
|
+
match += 1 if yield(elem)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
if digits
|
|
14
|
+
((match.to_f / count.to_f) * 100).round(digits)
|
|
15
|
+
else
|
|
16
|
+
((match.to_f / count.to_f) * 100).to_i
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# environments plugin
|
|
4
|
+
class Denmark::Plugins::Issues
|
|
5
|
+
def self.description
|
|
6
|
+
# This is a Ruby squiggle heredoc; just a multi-line string with indentation removed
|
|
7
|
+
<<~DESCRIPTION
|
|
8
|
+
This smell test infers trends about the responsiveness of a module's maintainer(s)
|
|
9
|
+
based on patterns in its repository issues.
|
|
10
|
+
DESCRIPTION
|
|
11
|
+
end
|
|
12
|
+
def self.setup
|
|
13
|
+
# run just before evaluating this plugin
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.run(mod, repo)
|
|
17
|
+
# return an array of hashes representing any smells discovered
|
|
18
|
+
response = Array.new
|
|
19
|
+
|
|
20
|
+
today = Date.today
|
|
21
|
+
unanswered = repo.issues.percent_of {|i| i.comments == 0 }
|
|
22
|
+
ancient = repo.issues.percent_of {|i| (today - i.created_at.to_date).to_i > 1095 } # more than 3 years old
|
|
23
|
+
|
|
24
|
+
if unanswered > 25
|
|
25
|
+
response << {
|
|
26
|
+
severity: :orange,
|
|
27
|
+
message: "#{unanswered}% of the issues in this module's repository have no responses.",
|
|
28
|
+
explanation: "Sometimes when issues are not responded to, it means that the project is no longer being maintained. You might consider contacting the maintainer to determine the status of the project.",
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
if ancient > 50
|
|
33
|
+
response << {
|
|
34
|
+
severity: :yellow,
|
|
35
|
+
message: "#{ancient}% of the issues in this module's repository are more than 3 years old.",
|
|
36
|
+
explanation: "Many very old issues may indicate that the maintainer is not responding to community feedback.",
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
response
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.cleanup
|
|
44
|
+
# run just after evaluating this plugin
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# environments plugin
|
|
4
|
+
class Denmark::Plugins::Metadata
|
|
5
|
+
def self.description
|
|
6
|
+
# This is a Ruby squiggle heredoc; just a multi-line string with indentation removed
|
|
7
|
+
<<~DESCRIPTION
|
|
8
|
+
This smell test inspects the module's metadata for signs of something fishy. It will also compare
|
|
9
|
+
that metadata to what exists in the module's git repository.
|
|
10
|
+
DESCRIPTION
|
|
11
|
+
end
|
|
12
|
+
def self.setup
|
|
13
|
+
# run just before evaluating this plugin
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.run(mod, repo)
|
|
17
|
+
# return an array of hashes representing any smells discovered
|
|
18
|
+
response = Array.new
|
|
19
|
+
|
|
20
|
+
release_date = Date.parse(mod.releases.first.updated_at).to_date
|
|
21
|
+
prev_release = Date.parse(mod.releases[1].updated_at).to_date
|
|
22
|
+
version = mod.releases.first.version
|
|
23
|
+
changelog = mod.releases.first.changelog
|
|
24
|
+
|
|
25
|
+
repo_metadata = JSON.parse(repo.file_content('metadata.json'))
|
|
26
|
+
repo_changelog = repo.file_content('CHANGELOG.md') || repo.file_content('CHANGELOG')
|
|
27
|
+
latest_tag = repo.tags.first.name
|
|
28
|
+
latest_tag_date = repo.commit_date(repo.tags.first.commit.sha)
|
|
29
|
+
|
|
30
|
+
if (Date.today - release_date) > 365
|
|
31
|
+
response << {
|
|
32
|
+
severity: :yellow,
|
|
33
|
+
message: "The most current module release is more than a year old.",
|
|
34
|
+
explanation: "Sometimes when issues are not responded to, it means that the project is no longer being maintained. You might consider contacting the maintainer to determine the status of the project.",
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if version != repo_metadata[:version]
|
|
39
|
+
response << {
|
|
40
|
+
severity: :red,
|
|
41
|
+
message: "The version released on the Forge does not match the version in the repository.",
|
|
42
|
+
explanation: "Validate that the Forge release is not compromised and is the latest released version.",
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if changelog != repo_changelog
|
|
47
|
+
response << {
|
|
48
|
+
severity: :green,
|
|
49
|
+
message: "The module changelog on the Forge does not match what's in the repository.",
|
|
50
|
+
explanation: "This is not necessarily a problem. Some developers choose to update the changelog iteratively as they merge pull requests instead of all at release time. Still, it's worth double checking.",
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
if version != latest_tag
|
|
55
|
+
response << {
|
|
56
|
+
severity: :yellow,
|
|
57
|
+
message: "The version released on the Forge does not match the latest tag in the repo.",
|
|
58
|
+
explanation: "This sometimes just indicates sloppy release practices, but could indicate a compromised Forge release.",
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if release_date != latest_tag_date
|
|
63
|
+
response << {
|
|
64
|
+
severity: :yellow,
|
|
65
|
+
message: "The module was not published to the Forge on the same day that the latest release was tagged.",
|
|
66
|
+
explanation: "This sometimes just indicates sloppy release practices, but could indicate a compromised Forge release.",
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if (release_date - prev_release) > 365
|
|
71
|
+
response << {
|
|
72
|
+
severity: :green,
|
|
73
|
+
message: "There was a gap of at least a year between the last two releases.",
|
|
74
|
+
explanation: "A large gap between releases often shows sporadic maintenance. This is not always bad.",
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
response
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def self.cleanup
|
|
82
|
+
# run just after evaluating this plugin
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# environments plugin
|
|
4
|
+
class Denmark::Plugins::PullRequests
|
|
5
|
+
def self.description
|
|
6
|
+
# This is a Ruby squiggle heredoc; just a multi-line string with indentation removed
|
|
7
|
+
<<~DESCRIPTION
|
|
8
|
+
This smell test infers trends about the responsiveness of a module's maintainer(s)
|
|
9
|
+
based on patterns in its repository pull requests.
|
|
10
|
+
DESCRIPTION
|
|
11
|
+
end
|
|
12
|
+
def self.setup
|
|
13
|
+
# run just before evaluating this plugin
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.run(mod, repo)
|
|
17
|
+
# return an array of hashes representing any smells discovered
|
|
18
|
+
response = Array.new
|
|
19
|
+
|
|
20
|
+
today = Date.today
|
|
21
|
+
unanswered = repo.pull_requests.percent_of {|i| i.comments == 0 }
|
|
22
|
+
ancient = repo.pull_requests.percent_of {|i| (today - i.created_at.to_date).to_i > 1095 } # more than 3 years old
|
|
23
|
+
|
|
24
|
+
if unanswered > 10
|
|
25
|
+
response << {
|
|
26
|
+
severity: :orange,
|
|
27
|
+
message: "#{unanswered}% of the pull requests in this module's repository have not been reviewed.",
|
|
28
|
+
explanation: "Sometimes when pull requests are not reviewed, it means that the project is no longer being maintained. You might consider contacting the maintainer to determine the status of the project.",
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
if ancient > 50
|
|
33
|
+
response << {
|
|
34
|
+
severity: :yellow,
|
|
35
|
+
message: "#{ancient}% of the pull requests in this module's repository are more than 3 years old.",
|
|
36
|
+
explanation: "Many very old pull requests may indicate that the maintainer is not merging community contributions.",
|
|
37
|
+
}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
response
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.cleanup
|
|
44
|
+
# run just after evaluating this plugin
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'little-plugger'
|
|
4
|
+
|
|
5
|
+
# metrics class
|
|
6
|
+
class Denmark::Plugins
|
|
7
|
+
extend LittlePlugger(path: 'denmark/plugins', module: Denmark::Plugins)
|
|
8
|
+
|
|
9
|
+
def initialize(options)
|
|
10
|
+
if options[:enable]
|
|
11
|
+
disable = Denmark::Plugins.plugins.keys - options[:enable].map(&:to_sym)
|
|
12
|
+
options[:disable] ||= Array.new
|
|
13
|
+
options[:disable].concat disable
|
|
14
|
+
end
|
|
15
|
+
Denmark::Plugins.disregard_plugins(*options[:disable])
|
|
16
|
+
Denmark::Plugins.initialize_plugins
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def list
|
|
20
|
+
str = " Available smell test plugins\n"
|
|
21
|
+
str += " ===============================\n\n"
|
|
22
|
+
Denmark::Plugins.plugins.each do |name, plugin|
|
|
23
|
+
str += name.to_s
|
|
24
|
+
str += "\n--------\n"
|
|
25
|
+
str += plugin.description.strip
|
|
26
|
+
str += "\n\n"
|
|
27
|
+
end
|
|
28
|
+
str
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def run(mod, repo)
|
|
32
|
+
results = []
|
|
33
|
+
Denmark::Plugins.plugins.each do |_name, plugin|
|
|
34
|
+
plugin.setup
|
|
35
|
+
results.concat plugin.run(mod, repo)
|
|
36
|
+
plugin.cleanup
|
|
37
|
+
end
|
|
38
|
+
results
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Denmark::Repository
|
|
4
|
+
def initialize(url)
|
|
5
|
+
# This tool only makes sense for public repos, so don't bother to be too smart.
|
|
6
|
+
case url
|
|
7
|
+
when /github\.com/
|
|
8
|
+
require 'octokit'
|
|
9
|
+
@flavor = :github
|
|
10
|
+
@client = Octokit::Client.new(:access_token => Denmark.config(:github, :token))
|
|
11
|
+
@repo = Octokit::Repository.from_url(url).slug
|
|
12
|
+
|
|
13
|
+
when /gitlab\.com/
|
|
14
|
+
require 'gitlab'
|
|
15
|
+
@flavor = :gitlab
|
|
16
|
+
@client = Gitlab.client(
|
|
17
|
+
endpoint: 'https://gitlab.com/api/v4',
|
|
18
|
+
private_token: Denmark.config(:gitlab, :token),
|
|
19
|
+
)
|
|
20
|
+
@repo = URI.parse(url).path[1..-1]
|
|
21
|
+
|
|
22
|
+
else
|
|
23
|
+
raise "Unsupported git source: '#{url}'"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def client
|
|
28
|
+
@client
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def pull_requests
|
|
32
|
+
case @flavor
|
|
33
|
+
when :github
|
|
34
|
+
@client.issues(@repo).select {|i| i[:pull_request] }
|
|
35
|
+
when :gitlab
|
|
36
|
+
@client.merge_requests(@repo)
|
|
37
|
+
else
|
|
38
|
+
Array.new
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def merge_requests
|
|
43
|
+
pull_requests
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def issues
|
|
47
|
+
case @flavor
|
|
48
|
+
when :github
|
|
49
|
+
@client.issues(@repo).reject {|i| i[:pull_request] }
|
|
50
|
+
when :gitlab
|
|
51
|
+
@client.issues(@repo)
|
|
52
|
+
else
|
|
53
|
+
Array.new
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def tags
|
|
58
|
+
case @flavor
|
|
59
|
+
when :github, :gitlab
|
|
60
|
+
@client.tags(@repo)
|
|
61
|
+
else
|
|
62
|
+
Array.new
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def file_content(path)
|
|
67
|
+
case @flavor
|
|
68
|
+
when :github
|
|
69
|
+
Base64.decode64(client.contents(@repo, :path => path).content) rescue nil
|
|
70
|
+
when :gitlab
|
|
71
|
+
client.file_contents(@repo, path)
|
|
72
|
+
else
|
|
73
|
+
''
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def commit(sha)
|
|
78
|
+
case @flavor
|
|
79
|
+
when :github, :gitlab
|
|
80
|
+
@client.commit(@repo, sha)
|
|
81
|
+
else
|
|
82
|
+
Array.new
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def commits
|
|
87
|
+
case @flavor
|
|
88
|
+
when :github, :gitlab
|
|
89
|
+
@client.commits(@repo)
|
|
90
|
+
else
|
|
91
|
+
Array.new
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def commit_date(sha)
|
|
96
|
+
case @flavor
|
|
97
|
+
when :github
|
|
98
|
+
@client.commit(@repo, sha).commit.committer.date.to_date
|
|
99
|
+
when :gitlab
|
|
100
|
+
@client.commit(@repo, sha).commit.created_at.to_date
|
|
101
|
+
else
|
|
102
|
+
Array.new
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def commits_since_tag(tag = nil)
|
|
109
|
+
tag ||= tags[0]
|
|
110
|
+
|
|
111
|
+
case @flavor
|
|
112
|
+
when :github
|
|
113
|
+
@client.commits_since(@repo, tag.commit.committer.date)
|
|
114
|
+
when :gitlab
|
|
115
|
+
@client.commits(@repo, since: tag.commit.created_at)
|
|
116
|
+
else
|
|
117
|
+
Array.new
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def commits_to_file(path)
|
|
122
|
+
case @flavor
|
|
123
|
+
when :github, :gitlab
|
|
124
|
+
@client.commits(@repo, path: path)
|
|
125
|
+
else
|
|
126
|
+
Array.new
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end
|
data/lib/denmark.rb
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'colorize'
|
|
5
|
+
require 'httpclient'
|
|
6
|
+
require 'puppet_forge'
|
|
7
|
+
require 'denmark/plugins'
|
|
8
|
+
require 'denmark/repository'
|
|
9
|
+
require 'denmark/monkeypatches'
|
|
10
|
+
|
|
11
|
+
class Denmark
|
|
12
|
+
PuppetForge.user_agent = "Denmark Module Smell Checker/#{Denmark::VERSION}"
|
|
13
|
+
|
|
14
|
+
def self.config=(arg)
|
|
15
|
+
raise "Requires a Hash to set config, not a #{arg.class}" unless arg.is_a? Hash
|
|
16
|
+
@config = arg
|
|
17
|
+
end
|
|
18
|
+
def self.config(*args)
|
|
19
|
+
if args.empty?
|
|
20
|
+
@config
|
|
21
|
+
else
|
|
22
|
+
@config.dig(*args)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def self.list(options)
|
|
28
|
+
puts
|
|
29
|
+
puts Denmark::Plugins.new(options).list
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.evaluate(slug, options)
|
|
33
|
+
@options = options
|
|
34
|
+
slug.sub!('/', '-')
|
|
35
|
+
begin
|
|
36
|
+
mod = PuppetForge::Module.find(slug)
|
|
37
|
+
rescue Faraday::BadRequestError, Faraday::ResourceNotFound
|
|
38
|
+
raise "The module `#{slug}` was not found on the Puppet Forge."
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
repo = Denmark::Repository.new(mod.homepage_url)
|
|
42
|
+
data = Denmark::Plugins.new(options).run(mod, repo)
|
|
43
|
+
|
|
44
|
+
case options[:format]
|
|
45
|
+
when 'json'
|
|
46
|
+
puts JSON.pretty_generate(data)
|
|
47
|
+
when 'human'
|
|
48
|
+
generate_report(data)
|
|
49
|
+
else
|
|
50
|
+
raise 'unknown format'
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.generate_report(data)
|
|
55
|
+
if data.empty?
|
|
56
|
+
puts "Congrats, no smells discovered"
|
|
57
|
+
else
|
|
58
|
+
puts
|
|
59
|
+
[:red, :orange, :yellow, :green].each do |severity|
|
|
60
|
+
alerts = data.select {|i| i[:severity] == severity}
|
|
61
|
+
next unless alerts.size > 0
|
|
62
|
+
|
|
63
|
+
puts "[#{severity.upcase}] alerts:".colorize(severity)
|
|
64
|
+
alerts.each do |alert|
|
|
65
|
+
puts " #{alert[:message]}"
|
|
66
|
+
puts " > #{alert[:explanation]}" if @options[:detail]
|
|
67
|
+
end
|
|
68
|
+
puts
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def self.info(slug)
|
|
75
|
+
mod = PuppetForge::Module.find(slug)
|
|
76
|
+
|
|
77
|
+
puts mod.owner.username
|
|
78
|
+
puts mod.owner.display_name
|
|
79
|
+
puts mod.current_release.version
|
|
80
|
+
puts mod.current_release.created_at
|
|
81
|
+
puts mod.current_release.changelog
|
|
82
|
+
puts mod.current_release.reference
|
|
83
|
+
puts mod.current_release.license
|
|
84
|
+
puts mod.homepage_url
|
|
85
|
+
puts mod.current_release.metadata['project_page']
|
|
86
|
+
puts mod.current_release.metadata['source']
|
|
87
|
+
puts mod.issues_url
|
|
88
|
+
|
|
89
|
+
client = Octokit::Client.new
|
|
90
|
+
repo = Octokit::Repository.from_url(mod.homepage_url, options)
|
|
91
|
+
|
|
92
|
+
require 'pry'
|
|
93
|
+
binding.pry
|
|
94
|
+
|
|
95
|
+
puts client.pull_requests(repo)
|
|
96
|
+
puts client.list_issues(repo)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def github_client
|
|
101
|
+
@token ||= ENV['GITHUB_TOKEN'] || `git config --global github.token`.chomp
|
|
102
|
+
|
|
103
|
+
if @token.empty?
|
|
104
|
+
puts "You need to generate a GitHub token:"
|
|
105
|
+
puts "\t * https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line"
|
|
106
|
+
puts "\t * git config --global github.token <token>"
|
|
107
|
+
puts
|
|
108
|
+
puts "Export that as the `GITHUB_TOKEN` environment variable or put it in your ~/.gitconfig."
|
|
109
|
+
exit 1
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
begin
|
|
113
|
+
client = Octokit::Client.new(:access_token => @token)
|
|
114
|
+
rescue => e
|
|
115
|
+
puts "Github login error: #{e.message}"
|
|
116
|
+
exit 1
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
client
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
metadata
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: denmark
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Ben Ford
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-02-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: json
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: gli
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: httpclient
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: little-plugger
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '1.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: puppet_forge
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: semantic_puppet
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '1.0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '1.0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: octokit
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '4.0'
|
|
104
|
+
type: :runtime
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '4.0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: gitlab
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '4.0'
|
|
118
|
+
type: :runtime
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '4.0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: colorize
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0.8'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0.8'
|
|
139
|
+
description: |
|
|
140
|
+
Denmark will check a Puppet module for things you should be concerned about, like signs of an
|
|
141
|
+
unmaintained module. It uses the Puppet Forge API and GitHub/GitLab APIs to discover information
|
|
142
|
+
about the module.
|
|
143
|
+
email: ben.ford@puppet.com
|
|
144
|
+
executables:
|
|
145
|
+
- denmark
|
|
146
|
+
extensions: []
|
|
147
|
+
extra_rdoc_files: []
|
|
148
|
+
files:
|
|
149
|
+
- LICENSE
|
|
150
|
+
- README.md
|
|
151
|
+
- bin/denmark
|
|
152
|
+
- lib/denmark.rb
|
|
153
|
+
- lib/denmark/monkeypatches.rb
|
|
154
|
+
- lib/denmark/plugins.rb
|
|
155
|
+
- lib/denmark/plugins/issues.rb
|
|
156
|
+
- lib/denmark/plugins/metadata.rb
|
|
157
|
+
- lib/denmark/plugins/pull_requests.rb
|
|
158
|
+
- lib/denmark/repository.rb
|
|
159
|
+
- lib/denmark/version.rb
|
|
160
|
+
homepage: https://github.com/binford2k/denmark
|
|
161
|
+
licenses:
|
|
162
|
+
- Apache-2.0
|
|
163
|
+
metadata: {}
|
|
164
|
+
post_install_message:
|
|
165
|
+
rdoc_options: []
|
|
166
|
+
require_paths:
|
|
167
|
+
- lib
|
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
169
|
+
requirements:
|
|
170
|
+
- - ">="
|
|
171
|
+
- !ruby/object:Gem::Version
|
|
172
|
+
version: '0'
|
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
|
+
requirements:
|
|
175
|
+
- - ">="
|
|
176
|
+
- !ruby/object:Gem::Version
|
|
177
|
+
version: '0'
|
|
178
|
+
requirements: []
|
|
179
|
+
rubygems_version: 3.0.3.1
|
|
180
|
+
signing_key:
|
|
181
|
+
specification_version: 4
|
|
182
|
+
summary: A quick smell test for Puppet modules to help identify concerns.
|
|
183
|
+
test_files: []
|