danger-typos 0.1.0
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/.rubocop.yml +149 -0
- data/LICENSE.txt +22 -0
- data/README.md +90 -0
- data/Rakefile +25 -0
- data/lib/danger_plugin.rb +3 -0
- data/lib/danger_typos.rb +3 -0
- data/lib/typos/gem_version.rb +5 -0
- data/lib/typos/plugin.rb +55 -0
- data/renovate.json +6 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7ca58a8024d01464f7d5f9b3849b6fc4ee9917864415af35b4c3e46df7eed4c4
|
4
|
+
data.tar.gz: 2e651317a64d71f85634a1dcab2b9ad31e447d9ddc335694cdb3c529715fc028
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b27895cc1ad3b248bc8594374f5832c244368daa950f350dc8e36f68ca5be2940116b263340892599083ac22ac448a4ad16573e5b573c42035cbfc2b311ceee
|
7
|
+
data.tar.gz: b4c12aacdde430d2d523f807dfb9f49bc36f5c79fb9aa21bf0937b9d3363a075a285fc86655e4c7cc2801932c0cb30b17ec2d3ac038e58dc2b98442e7bbe1c3a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
2
|
+
|
3
|
+
# If you don't like these settings, just delete this file :)
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
NewCops: enable
|
7
|
+
TargetRubyVersion: 3.2
|
8
|
+
|
9
|
+
Style/StringLiterals:
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
Enabled: true
|
12
|
+
|
13
|
+
# kind_of? is a good way to check a type
|
14
|
+
Style/ClassCheck:
|
15
|
+
EnforcedStyle: kind_of?
|
16
|
+
|
17
|
+
# specs sometimes have useless assignments, which is fine
|
18
|
+
Lint/UselessAssignment:
|
19
|
+
Exclude:
|
20
|
+
- '**/spec/**/*'
|
21
|
+
|
22
|
+
# We could potentially enable the 2 below:
|
23
|
+
Layout/FirstHashElementIndentation:
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Layout/HashAlignment:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
# HoundCI doesn't like this rule
|
30
|
+
Layout/DotPosition:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
# We allow !! as it's an easy way to convert ot boolean
|
34
|
+
Style/DoubleNegation:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
# Cop supports --auto-correct.
|
38
|
+
Lint/UnusedBlockArgument:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
# We want to allow class Fastlane::Class
|
42
|
+
Style/ClassAndModuleChildren:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
Metrics/AbcSize:
|
46
|
+
Max: 60
|
47
|
+
|
48
|
+
# The %w might be confusing for new users
|
49
|
+
Style/WordArray:
|
50
|
+
MinSize: 19
|
51
|
+
|
52
|
+
# raise and fail are both okay
|
53
|
+
Style/SignalException:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Better too much 'return' than one missing
|
57
|
+
Style/RedundantReturn:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
# Having if in the same line might not always be good
|
61
|
+
Style/IfUnlessModifier:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
# and and or is okay
|
65
|
+
Style/AndOr:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
# Configuration parameters: CountComments.
|
69
|
+
Metrics/ClassLength:
|
70
|
+
Max: 350
|
71
|
+
|
72
|
+
Metrics/CyclomaticComplexity:
|
73
|
+
Max: 17
|
74
|
+
|
75
|
+
# Configuration parameters: AllowURI, URISchemes.
|
76
|
+
Layout/LineLength:
|
77
|
+
Max: 370
|
78
|
+
|
79
|
+
# Configuration parameters: CountKeywordArgs.
|
80
|
+
Metrics/ParameterLists:
|
81
|
+
Max: 10
|
82
|
+
|
83
|
+
Metrics/PerceivedComplexity:
|
84
|
+
Max: 18
|
85
|
+
|
86
|
+
# Sometimes it's easier to read without guards
|
87
|
+
Style/GuardClause:
|
88
|
+
Enabled: false
|
89
|
+
|
90
|
+
# something = if something_else
|
91
|
+
# that's confusing
|
92
|
+
Style/ConditionalAssignment:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
# Better to have too much self than missing a self
|
96
|
+
Style/RedundantSelf:
|
97
|
+
Enabled: false
|
98
|
+
|
99
|
+
Metrics/MethodLength:
|
100
|
+
Max: 60
|
101
|
+
|
102
|
+
# We're not there yet
|
103
|
+
Style/Documentation:
|
104
|
+
Enabled: false
|
105
|
+
|
106
|
+
# Adds complexity
|
107
|
+
Style/IfInsideElse:
|
108
|
+
Enabled: false
|
109
|
+
|
110
|
+
# danger specific
|
111
|
+
|
112
|
+
Style/BlockComments:
|
113
|
+
Enabled: false
|
114
|
+
|
115
|
+
Layout/MultilineMethodCallIndentation:
|
116
|
+
EnforcedStyle: indented
|
117
|
+
|
118
|
+
# FIXME: 25
|
119
|
+
Metrics/BlockLength:
|
120
|
+
Max: 345
|
121
|
+
Exclude:
|
122
|
+
- "**/*_spec.rb"
|
123
|
+
|
124
|
+
Style/MixinGrouping:
|
125
|
+
Enabled: false
|
126
|
+
|
127
|
+
Naming/FileName:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
Layout/HeredocIndentation:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
Style/SpecialGlobalVars:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
Style/PercentLiteralDelimiters:
|
137
|
+
PreferredDelimiters:
|
138
|
+
"%": ()
|
139
|
+
"%i": ()
|
140
|
+
"%q": ()
|
141
|
+
"%Q": ()
|
142
|
+
"%r": "{}"
|
143
|
+
"%s": ()
|
144
|
+
"%w": ()
|
145
|
+
"%W": ()
|
146
|
+
"%x": ()
|
147
|
+
|
148
|
+
Security/YAMLLoad:
|
149
|
+
Enabled: false
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2025 Kyosuke Takayama <loiseau@gmail.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# danger-typos
|
2
|
+
|
3
|
+
[Danger](http://danger.systems/ruby/) plugin for [typos](https://github.com/crate-ci/typos).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install danger-typos
|
8
|
+
|
9
|
+
`typos` also needs to be installed before you run Danger.
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Add this to Dangerfile.
|
14
|
+
|
15
|
+
```
|
16
|
+
typos.run
|
17
|
+
```
|
18
|
+
|
19
|
+
If you want to specify typos bin file, you can set a bin path to the binary_path parameter.
|
20
|
+
|
21
|
+
```
|
22
|
+
typos.binary_path = "path/to/typos"
|
23
|
+
typos.run
|
24
|
+
```
|
25
|
+
|
26
|
+
|
27
|
+
### GitHub actions
|
28
|
+
|
29
|
+
```yaml
|
30
|
+
name: Danger
|
31
|
+
|
32
|
+
on: [pull_request]
|
33
|
+
|
34
|
+
jobs:
|
35
|
+
danger:
|
36
|
+
runs-on: ubuntu-latest
|
37
|
+
if: github.event_name == 'pull_request'
|
38
|
+
steps:
|
39
|
+
- uses: actions/checkout@v2
|
40
|
+
- uses: ruby/setup-ruby@v1
|
41
|
+
with:
|
42
|
+
ruby-version: 3.4
|
43
|
+
bundler-cache: true
|
44
|
+
|
45
|
+
- name: Install typos
|
46
|
+
uses: baptiste0928/cargo-install@v3
|
47
|
+
with:
|
48
|
+
crate: typos-cli
|
49
|
+
version: 1.29.7
|
50
|
+
|
51
|
+
- run: bundle exec danger
|
52
|
+
env:
|
53
|
+
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
54
|
+
```
|
55
|
+
|
56
|
+
|
57
|
+
### GitHub actions
|
58
|
+
|
59
|
+
directly install typos from binary
|
60
|
+
|
61
|
+
```yaml
|
62
|
+
name: Danger
|
63
|
+
|
64
|
+
on: [pull_request]
|
65
|
+
|
66
|
+
jobs:
|
67
|
+
danger:
|
68
|
+
runs-on: ubuntu-latest
|
69
|
+
if: github.event_name == 'pull_request'
|
70
|
+
steps:
|
71
|
+
- uses: actions/checkout@v2
|
72
|
+
- uses: ruby/setup-ruby@v1
|
73
|
+
with:
|
74
|
+
ruby-version: 3.4
|
75
|
+
bundler-cache: true
|
76
|
+
|
77
|
+
- name: Install typos
|
78
|
+
run: |
|
79
|
+
wget https://github.com/crate-ci/typos/releases/download/v1.29.7/typos-v1.29.7-x86_64-unknown-linux-musl.tar.gz
|
80
|
+
tar xf typos-v1.29.7-x86_64-unknown-linux-musl.tar.gz
|
81
|
+
mkdir -p $HOME/.cargo/bin
|
82
|
+
mv typos $HOME/.cargo/bin/
|
83
|
+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
84
|
+
typos --version
|
85
|
+
|
86
|
+
- run: bundle exec danger
|
87
|
+
env:
|
88
|
+
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
89
|
+
```
|
90
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:specs)
|
8
|
+
|
9
|
+
task default: :specs
|
10
|
+
|
11
|
+
task :spec do
|
12
|
+
Rake::Task["specs"].invoke
|
13
|
+
Rake::Task["rubocop"].invoke
|
14
|
+
Rake::Task["spec_docs"].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run RuboCop on the lib/specs directory"
|
18
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
19
|
+
task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Ensure that the plugin passes `danger plugins lint`"
|
23
|
+
task :spec_docs do
|
24
|
+
sh "bundle exec danger plugins lint"
|
25
|
+
end
|
data/lib/danger_typos.rb
ADDED
data/lib/typos/plugin.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "open3"
|
5
|
+
|
6
|
+
module Danger
|
7
|
+
# [Danger](http://danger.systems/ruby/) plugin for [typos](https://github.com/crate-ci/typos).
|
8
|
+
#
|
9
|
+
# @example Run typos and send warn comment.
|
10
|
+
#
|
11
|
+
# typos.binary_path = "path/to/typos"
|
12
|
+
# typos.run
|
13
|
+
#
|
14
|
+
# @see ktakayama/danger-typos
|
15
|
+
# @tags typos
|
16
|
+
#
|
17
|
+
class DangerTypos < Plugin
|
18
|
+
# typos path
|
19
|
+
# @return [String]
|
20
|
+
attr_accessor :binary_path
|
21
|
+
|
22
|
+
# Execute typos
|
23
|
+
# @return [void]
|
24
|
+
def run
|
25
|
+
return if target_files.empty?
|
26
|
+
|
27
|
+
args = ["--force-exclude", "--format", "json"] + target_files
|
28
|
+
stdout, = Open3.capture3(cmd_path, *args)
|
29
|
+
|
30
|
+
stdout.split("\n").each do |result|
|
31
|
+
data = JSON.parse(result)
|
32
|
+
next if data["type"] != "typo"
|
33
|
+
|
34
|
+
warn(
|
35
|
+
"`#{data['typo']}` should be `#{data['corrections'].first}`",
|
36
|
+
file: data["path"],
|
37
|
+
line: data["line_num"]
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def cmd_path
|
45
|
+
return binary_path if binary_path
|
46
|
+
|
47
|
+
cmd = File.expand_path("~/.cargo/bin/typos")
|
48
|
+
File.exist?(cmd) ? cmd : "typos"
|
49
|
+
end
|
50
|
+
|
51
|
+
def target_files
|
52
|
+
((git.added_files + (git.modified_files - git.deleted_files)) - git.renamed_files.map { |r| r[:before] } + git.renamed_files.map { |r| r[:after] }).uniq
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/renovate.json
ADDED
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-typos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyosuke Takayama
|
8
|
+
bindir: exe
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-02-15 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: danger-plugin-api
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '1.0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '1.0'
|
26
|
+
description: Danger plugin for typos.
|
27
|
+
email:
|
28
|
+
- loiseau@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".rubocop.yml"
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- lib/danger_plugin.rb
|
38
|
+
- lib/danger_typos.rb
|
39
|
+
- lib/typos/gem_version.rb
|
40
|
+
- lib/typos/plugin.rb
|
41
|
+
- renovate.json
|
42
|
+
homepage: https://github.com/ktakayama/danger-typos
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata:
|
46
|
+
homepage_uri: https://github.com/ktakayama/danger-typos
|
47
|
+
source_code_uri: https://github.com/ktakayama/danger-typos
|
48
|
+
changelog_uri: https://github.com/ktakayama/danger-typos
|
49
|
+
rubygems_mfa_required: 'true'
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 3.2.0
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.6.2
|
65
|
+
specification_version: 4
|
66
|
+
summary: Danger plugin for typos.
|
67
|
+
test_files: []
|