Skip to content

Commit

Permalink
Add spell checking GitHub Actions workflow
Browse files Browse the repository at this point in the history
This PR adds spell checking GitHub Actions workflow and fixes typos.

The following two tools are used for spell checking.

- misspell (requires Golang) ... https://github.com/client9/misspell
- codespell (requires Python) ... https://github.com/codespell-project/codespell

For contributors who don't have Golang and Python installed, it is only
CONTRIBUTING.md and not run with `rake` task.

This GitHub Actions configuration is based on the Rails's spell checking workflow.
https://github.com/rails/rails/blob/v7.0.0.alpha2/.github/workflows/lint.yml
  • Loading branch information
koic authored and bbatsov committed Sep 28, 2021
1 parent 14ca0ce commit de4f7cd
Show file tree
Hide file tree
Showing 41 changed files with 130 additions and 69 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/spell_checking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Spell Checking

on: [pull_request]

jobs:
codespell:
name: Check spelling all files with codespell
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install codespell
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Check spelling with codespell
run: codespell --ignore-words=codespell.txt || exit 1
misspell:
name: Check spelling all files in commit with misspell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install
run: wget -O - -q https://git.io/misspell | sh -s -- -b .
- name: Misspell
run: git ls-files --empty-directory | xargs ./misspell -i 'enviromnent' -error
18 changes: 9 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

### Bug fixes

* [#10017](https://github.com/rubocop/rubocop/pull/10017): Fixan error for `Layout/RescueEnsureAlignment` when using zsuper with block. ([@koic][])
* [#10017](https://github.com/rubocop/rubocop/pull/10017): Fix an error for `Layout/RescueEnsureAlignment` when using zsuper with block. ([@koic][])
* [#10011](https://github.com/rubocop/rubocop/issues/10011): Fix a false positive for `Style/RedundantSelfAssignmentBranch` when using instance variable, class variable, and global variable. ([@koic][])
* [#10010](https://github.com/rubocop/rubocop/issues/10010): Fix a false positive for `Style/DoubleNegation` when `!!` is used at return location and before `rescue` keyword. ([@koic][])
* [#10014](https://github.com/rubocop/rubocop/issues/10014): Fix `Style/Encoding` to handle more situations properly. ([@dvandersluis][])
Expand Down Expand Up @@ -157,7 +157,7 @@
* [#9882](https://github.com/rubocop/rubocop/pull/9882): Fix an incorrect auto-correct for `Layout/LineLength` when using heredoc as the first method argument and omitting parentheses. ([@koic][])
* [#7592](https://github.com/rubocop/rubocop/pull/7592): Add cop `Layout/LineEndStringConcatenationIndentation`. ([@jonas054][])
* [#9880](https://github.com/rubocop/rubocop/pull/9880): Fix a false positive for `Style/RegexpLiteral` when using a regexp starts with a blank as a method argument. ([@koic][])
* [#9888](https://github.com/rubocop/rubocop/pull/9888): Fix a false positive for `Layout/ClosingParenthesisIndentation` when using keyword arguemnts. ([@koic][])
* [#9888](https://github.com/rubocop/rubocop/pull/9888): Fix a false positive for `Layout/ClosingParenthesisIndentation` when using keyword arguments. ([@koic][])
* [#9886](https://github.com/rubocop/rubocop/pull/9886): Fix indentation in Style/ClassAndModuleChildren. ([@markburns][])

### Changes
Expand Down Expand Up @@ -1371,7 +1371,7 @@
* [#7236](https://github.com/rubocop/rubocop/pull/7236): Mark `Style/InverseMethods` auto-correct as incompatible with `Style/SymbolProc`. ([@drenmi][])
* [#7144](https://github.com/rubocop/rubocop/issues/7144): Fix `Style/Documentation` constant visibility declaration in namespace. ([@AdrienSldy][])
* [#7779](https://github.com/rubocop/rubocop/issues/7779): Fix a false positive for `Style/MultilineMethodCallIndentation` when using Ruby 2.7's numbered parameter. ([@koic][])
* [#7733](https://github.com/rubocop/rubocop/issues/7733): Fix rubocop-junit-formatter imcompatibility XML for JUnit formatter. ([@koic][])
* [#7733](https://github.com/rubocop/rubocop/issues/7733): Fix rubocop-junit-formatter incompatibility XML for JUnit formatter. ([@koic][])
* [#7767](https://github.com/rubocop/rubocop/issues/7767): Skip array literals in `Style/HashTransformValues` and `Style/HashTransformKeys`. ([@tejasbubane][])
* [#7791](https://github.com/rubocop/rubocop/issues/7791): Fix an error on auto-correction for `Layout/BlockEndNewline` when `}` of multiline block without processing is not on its own line. ([@koic][])
* [#7778](https://github.com/rubocop/rubocop/issues/7778): Fix a false positive for `Layout/EndAlignment` when a non-whitespace is used before the `end` keyword. ([@koic][])
Expand Down Expand Up @@ -1952,7 +1952,7 @@
### Bug fixes

* [#6627](https://github.com/rubocop/rubocop/pull/6627): Fix handling of hashes in trailing comma. ([@abrom][])
* [#6638](https://github.com/rubocop/rubocop/pull/6638): Fix `Rails/LinkToBlank` dectection to allow `rel: 'noreferer`. ([@fwininger][])
* [#6638](https://github.com/rubocop/rubocop/pull/6638): Fix `Rails/LinkToBlank` detection to allow `rel: 'noreferer`. ([@fwininger][])
* [#6623](https://github.com/rubocop/rubocop/pull/6623): Fix heredoc detection in trailing comma. ([@palkan][])
* [#6100](https://github.com/rubocop/rubocop/issues/6100): Fix a false positive in `Naming/ConstantName` cop when rhs is a conditional expression. ([@tatsuyafw][])
* [#6526](https://github.com/rubocop/rubocop/issues/6526): Fix a wrong line highlight in `Lint/ShadowedException` cop. ([@tatsuyafw][])
Expand Down Expand Up @@ -3382,7 +3382,7 @@
* [#2995](https://github.com/rubocop/rubocop/issues/2995): Removed deprecated path matching syntax. ([@gerrywastaken][])
* [#3025](https://github.com/rubocop/rubocop/pull/3025): Removed deprecation warnings for `rubocop-todo.yml`. ([@ptarjan][])
* [#3028](https://github.com/rubocop/rubocop/pull/3028): Add `define_method` to the default list of `IgnoredMethods` of `Style/SymbolProc`. ([@jastkand][])
* [#3064](https://github.com/rubocop/rubocop/pull/3064): `Style/SpaceAfterNot` highlights the entire expression instead of just the exlamation mark. ([@rrosenblum][])
* [#3064](https://github.com/rubocop/rubocop/pull/3064): `Style/SpaceAfterNot` highlights the entire expression instead of just the exclamation mark. ([@rrosenblum][])
* [#3085](https://github.com/rubocop/rubocop/pull/3085): Enable `Style/MultilineArrayBraceLayout` and `Style/MultilineHashBraceLayout` with the `symmetrical` style by default. ([@panthomakos][])
* [#3091](https://github.com/rubocop/rubocop/pull/3091): Enable `Style/MultilineMethodCallBraceLayout` and `Style/MultilineMethodDefinitionBraceLayout` with the `symmetrical` style by default. ([@panthomakos][])
* [#1830](https://github.com/rubocop/rubocop/pull/1830): `Style/PredicateName` now ignores the `spec/` directory, since there is a strong convention for using `have_*` and `be_*` helper methods in RSpec. ([@gylaz][])
Expand Down Expand Up @@ -3681,7 +3681,7 @@
* [#2066](https://github.com/rubocop/rubocop/issues/2066): `Style/TrivialAccessors` doesn't flag what appear to be trivial accessor method definitions, if they are nested inside a call to `instance_eval`. ([@alexdowad][])
* `Style/SymbolArray` doesn't flag arrays of symbols if a symbol contains a space character. ([@alexdowad][])
* `Style/SymbolArray` can auto-correct offenses. ([@alexdowad][])
* [#2546](https://github.com/rubocop/rubocop/issues/2546): Report when two `rubocop:disable` comments (not the single line kind) for a given cop apppear in a file with no `rubocop:enable` in between. ([@jonas054][])
* [#2546](https://github.com/rubocop/rubocop/issues/2546): Report when two `rubocop:disable` comments (not the single line kind) for a given cop appear in a file with no `rubocop:enable` in between. ([@jonas054][])
* [#2552](https://github.com/rubocop/rubocop/issues/2552): `Style/Encoding` can auto-correct files with a blank first line. ([@alexdowad][])
* [#2556](https://github.com/rubocop/rubocop/issues/2556): `Style/SpecialGlobalVariables` generates auto-config correctly. ([@alexdowad][])
* [#2565](https://github.com/rubocop/rubocop/issues/2565): Let `Style/SpaceAroundOperators` leave spacing around `=>` to `Style/AlignHash`. ([@jonas054][])
Expand Down Expand Up @@ -3904,7 +3904,7 @@
* [#2057](https://github.com/rubocop/rubocop/pull/2057): New cop `Lint/FormatParameterMismatch` checks for a mismatch between the number of fields expected in format/sprintf/% and what was passed to it. ([@edmz][])
* [#2010](https://github.com/rubocop/rubocop/pull/2010): Add `space` style for SpaceInsideStringInterpolation. ([@gotrevor][])
* [#2007](https://github.com/rubocop/rubocop/pull/2007): Allow any modifier before `def`, not only visibility modifiers. ([@fphilipe][])
* [#1980](https://github.com/rubocop/rubocop/pull/1980): `--auto-gen-config` now outputs an excluded files list for failed cops (up to a maxiumum of 15 files). ([@bmorrall][])
* [#1980](https://github.com/rubocop/rubocop/pull/1980): `--auto-gen-config` now outputs an excluded files list for failed cops (up to a maximum of 15 files). ([@bmorrall][])
* [#2004](https://github.com/rubocop/rubocop/pull/2004): Introduced `--exclude-limit COUNT` to configure how many files `--auto-gen-config` will exclude. ([@awwaiid][], [@jonas054][])
* [#1918](https://github.com/rubocop/rubocop/issues/1918): New configuration parameter `AllCops:DisabledByDefault` when set to `true` makes only cops found in user configuration enabled, which makes cop selection *opt-in*. ([@jonas054][])
* New cop `Performance/StringReplacement` checks for usages of `gsub` that can be replaced with `tr` or `delete`. ([@rrosenblum][])
Expand Down Expand Up @@ -4273,7 +4273,7 @@
* New cop `InfiniteLoop` checks for places where `Kernel#loop` should have been used. ([@bbatsov][])
* New cop `SymbolProc` checks for places where a symbol can be used as proc instead of a block. ([@bbatsov][])
* `UselessAssignment` cop now suggests a variable name for possible typos if there's a variable-ish identifier similar to the unused variable name in the same scope. ([@yujinakayama][])
* `PredicateName` cop now has separate configurations for prefices that denote predicate method names and predicate prefices that should be removed. ([@bbatsov][])
* `PredicateName` cop now has separate configurations for prefixes that denote predicate method names and predicate prefixes that should be removed. ([@bbatsov][])
* [#1272](https://github.com/rubocop/rubocop/issues/1272): `Tab` cop does auto-correction. ([@yous][])
* [#1274](https://github.com/rubocop/rubocop/issues/1274): `MultilineIfThen` cop does auto-correction. ([@bbatsov][])
* [#1279](https://github.com/rubocop/rubocop/issues/1279): `DotPosition` cop does auto-correction. ([@yous][])
Expand Down Expand Up @@ -5281,7 +5281,7 @@

* [#62](https://github.com/rubocop/rubocop/issues/62): Config files in ancestor directories are ignored if another exists in home directory.
* [#65](https://github.com/rubocop/rubocop/issues/65): Suggests to convert symbols `:==`, `:<=>` and the like to snake_case.
* [#66](https://github.com/rubocop/rubocop/issues/66): Does not crash on unreadable or unparseable files.
* [#66](https://github.com/rubocop/rubocop/issues/66): Does not crash on unreadable or unparsable files.
* [#70](https://github.com/rubocop/rubocop/issues/70): Support `alias` with bareword arguments.
* [#64](https://github.com/rubocop/rubocop/issues/64): Performance issue with Bundler.
* [#75](https://github.com/rubocop/rubocop/issues/75): Make it clear that some global variables require the use of the English library.
Expand Down
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ $ rubocop -V
* Open a [pull request][4] that relates to *only* one subject with a clear title
and description in grammatically correct, complete sentences.

### Spell Checking

We are running [misspell](https://github.com/client9/misspell) which is mainly written in
[Golang](https://golang.org/) to check spelling with [GitHub Actions](../.github/workflows/spell_checking.yml).
Correct commonly misspelled English words quickly with `misspell`. `misspell` is different from most other spell checkers
because it doesn't use a custom dictionary. You can run `misspell` locally against all files with:

$ find . -type f | xargs ./misspell -i 'enviromnent' -error

Notable `misspell` help options or flags are:

* `-i` string: ignore the following corrections, comma separated
* `-w`: Overwrite file with corrections (default is just to display)

We also run [codespell](https://github.com/codespell-project/codespell) with GitHub Actions to check spelling and
[codespell](https://pypi.org/project/codespell/) runs against a [small custom dictionary](../codespell.txt).
`codespell` is written in [Python](https://www.python.org/) and you can run it with:

$ codespell --ignore-words=codespell.txt

### Creating changelog entries

Changelog entries are just files under the `changelog/` folder that will be merged
Expand Down
8 changes: 8 additions & 0 deletions codespell.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ba
enviromnent
filetest
fo
irregardless
ofo
thi
upto
2 changes: 1 addition & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ AllCops:
# What MRI version of the Ruby interpreter is the inspected code intended to
# run on? (If there is more than one, set this to the lowest version.)
# If a value is specified for TargetRubyVersion then it is used. Acceptable
# values are specificed as a float (i.e. 3.0); the teeny version of Ruby
# values are specified as a float (i.e. 3.0); the teeny version of Ruby
# should not be included. If the project specifies a Ruby version in the
# .tool-versions or .ruby-version files, Gemfile or gems.rb file, RuboCop will
# try to determine the desired version of Ruby by inspecting the
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ In this example the `Exclude` would only include `bar.rb`.

Configuration files are pre-processed using the ERB templating mechanism. This
makes it possible to add dynamic content that will be evaluated when the
configuation file is read. For example, you could let RuboCop ignore all files
configuration file is read. For example, you could let RuboCop ignore all files
ignored by Git.

[source,yaml]
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/cops_gemspec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ Gem::Specification.new do |spec|
end
# accepted but not recommended, since
# Ruby does not really follow semantic versionning
# Ruby does not really follow semantic versioning
Gem::Specification.new do |spec|
spec.required_ruby_version = '~> 2.5'
end
Expand Down
8 changes: 4 additions & 4 deletions docs/modules/ROOT/pages/cops_lint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ if a.x != 0 && a.x != 0
do_something
end
def childs?
def child?
left_child || left_child
end
Expand Down Expand Up @@ -3476,7 +3476,7 @@ It emulates the following warning in Ruby 2.7:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
-e:1: warning: `_1' is reserved for numbered parameter; consider another name

Assiging to numbered parameter (from `_1` to `_9`) cause an error in Ruby 3.0.
Assigning to numbered parameter (from `_1` to `_9`) cause an error in Ruby 3.0.

% ruby -ve '_1 = :value'
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
Expand Down Expand Up @@ -4825,7 +4825,7 @@ given by `ruby -cw` prior to Ruby 2.6:

NOTE: Shadowing of variables in block passed to `Ractor.new` is allowed
because `Ractor` should not access outer variables.
eg. following syle is encouraged:
eg. following style is encouraged:

worker_id, pipe = env
Ractor.new(worker_id, pipe) do |worker_id, pipe|
Expand Down Expand Up @@ -5292,7 +5292,7 @@ end
| -
|===

This cop checks for "triple quotes" (strings delimted by any odd number
This cop checks for "triple quotes" (strings delimited by any odd number
of quotes greater than 1).

Ruby allows multiple strings to be implicitly concatenated by just
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ A long-term goal of RuboCop (and its core extensions) is to cover with cops all

== Philosophy

Early on RuboCop aimed to be an opinionated linter/formater that adhered very closely to the Ruby Style Guide (think `gofmt` and the like).
Early on RuboCop aimed to be an opinionated linter/formatter that adhered very closely to the Ruby Style Guide (think `gofmt` and the like).
In those days cops supported just a single style and you couldn't even turn individual cops off. Eventually, we realized
that in the Ruby community there were some many competing styles and preferences that it was going to be really
challenging to find one set of defaults that makes everyone happy. Part of this was Ruby's own culture and philosophy,
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Cop
# `add_global_offense`. Use the `processed_source` method to
# get the currently processed source being investigated.
#
# In case of invalid syntax / unparseable content,
# In case of invalid syntax / unparsable content,
# the callback `on_other_file` is called instead of all the other
# `on_...` callbacks.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/gemspec/required_ruby_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module Gemspec
# end
#
# # accepted but not recommended, since
# # Ruby does not really follow semantic versionning
# # Ruby does not really follow semantic versioning
# Gem::Specification.new do |spec|
# spec.required_ruby_version = '~> 2.5'
# end
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NodeMatcherDirective < Base
extend AutoCorrector
include RangeHelp

MSG = 'Preceed `%<method>s` with a `@!method` YARD directive.'
MSG = 'Precede `%<method>s` with a `@!method` YARD directive.'
MSG_WRONG_NAME = '`@!method` YARD directive has invalid method name, ' \
'use `%<expected>s` instead of `%<actual>s`.'
MSG_TOO_MANY = 'Multiple `@!method` YARD directives found for this matcher.'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Lint
# do_something
# end
#
# def childs?
# def child?
# left_child || left_child
# end
#
Expand Down
8 changes: 4 additions & 4 deletions lib/rubocop/cop/lint/deprecated_class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ def correctable?
end

def to_s
[class_constant, method].compact.join(delimeter)
[class_constant, method].compact.join(delimiter)
end

private

def delimeter
def delimiter
CLASS_METHOD_DELIMETER
end
end
Expand All @@ -81,12 +81,12 @@ def initialize(method, class_constant: nil, instance_method: false)
end

def to_s
[class_constant, method].compact.join(delimeter)
[class_constant, method].compact.join(delimiter)
end

private

def delimeter
def delimiter
instance_method? ? INSTANCE_METHOD_DELIMETER : CLASS_METHOD_DELIMETER
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/numbered_parameter_assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Lint
# ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]
# -e:1: warning: `_1' is reserved for numbered parameter; consider another name
#
# Assiging to numbered parameter (from `_1` to `_9`) cause an error in Ruby 3.0.
# Assigning to a numbered parameter (from `_1` to `_9`) causes an error in Ruby 3.0.
#
# % ruby -ve '_1 = :value'
# ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/shadowing_outer_local_variable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Lint
#
# NOTE: Shadowing of variables in block passed to `Ractor.new` is allowed
# because `Ractor` should not access outer variables.
# eg. following syle is encouraged:
# eg. following style is encouraged:
#
# worker_id, pipe = env
# Ractor.new(worker_id, pipe) do |worker_id, pipe|
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/symbol_conversion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def correct_hash_key(node)
# Although some operators can be converted to symbols normally
# (ie. `:==`), these are not accepted as hash keys and will
# raise a syntax error (eg. `{ ==: ... }`). Therefore, if the
# symbol does not start with an alpha-numeric or underscore, it
# symbol does not start with an alphanumeric or underscore, it
# will be ignored.
return unless node.value.to_s.match?(/\A[a-z0-9_]/i)

Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/lint/triple_quotes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module RuboCop
module Cop
module Lint
# This cop checks for "triple quotes" (strings delimted by any odd number
# This cop checks for "triple quotes" (strings delimited by any odd number
# of quotes greater than 1).
#
# Ruby allows multiple strings to be implicitly concatenated by just
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/cop/style/line_end_concatenation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Style
# the end of a line.
#
# @safety
# This cop is unsafe because it canot be guaranteed that the
# This cop is unsafe because it cannot be guaranteed that the
# receiver is a string, in which case replacing `<<` with `\`
# would result in a syntax error.
#
Expand Down

0 comments on commit de4f7cd

Please sign in to comment.