diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index b124ae3077..da3268bb95 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -3,8 +3,27 @@ name: Lint
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 Misspell
+ name: Check spelling all files in commit with misspell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
diff --git a/actionpack/test/controller/parameters/parameters_permit_test.rb b/actionpack/test/controller/parameters/parameters_permit_test.rb
index fbfe24059b..6e25a1eae9 100644
--- a/actionpack/test/controller/parameters/parameters_permit_test.rb
+++ b/actionpack/test/controller/parameters/parameters_permit_test.rb
@@ -253,12 +253,12 @@ class ParametersPermitTest < ActiveSupport::TestCase
assert_not_predicate permitted[:users].last, :permitted?
end
- test "fetch doesnt raise ParameterMissing exception if there is a default" do
+ test "fetch doesn't raise ParameterMissing exception if there is a default" do
assert_equal "monkey", @params.fetch(:foo, "monkey")
assert_equal "monkey", @params.fetch(:foo) { "monkey" }
end
- test "fetch doesnt raise ParameterMissing exception if there is a default that is nil" do
+ test "fetch doesn't raise ParameterMissing exception if there is a default that is nil" do
assert_nil @params.fetch(:foo, nil)
assert_nil @params.fetch(:foo) { nil }
end
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index fe691af2ae..8c2397cf48 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -292,7 +292,7 @@ class RescueControllerTest < ActionController::TestCase
assert_response :unprocessable_entity
end
- test "rescue when cause has handler, but wrapper doesnt" do
+ test "rescue when cause has handler, but wrapper doesn't" do
get :exception_with_no_handler_for_wrapper
assert_response :unprocessable_entity
end
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index 346d327ea5..cab42c3cd9 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -597,7 +597,7 @@ class RequestCookie < BaseRequestTest
end
class RequestParamsParsing < BaseRequestTest
- test "doesnt break when content type has charset" do
+ test "doesn't break when content type has charset" do
request = stub_request(
"REQUEST_METHOD" => "POST",
"CONTENT_LENGTH" => "flamenco=love".length,
@@ -608,7 +608,7 @@ class RequestParamsParsing < BaseRequestTest
assert_equal({ "flamenco" => "love" }, request.request_parameters)
end
- test "doesnt interpret request uri as query string when missing" do
+ test "doesn't interpret request uri as query string when missing" do
request = stub_request("REQUEST_URI" => "foo")
assert_equal({}, request.query_parameters)
end
diff --git a/actionview/test/template/javascript_helper_test.rb b/actionview/test/template/javascript_helper_test.rb
index 4b7284d15b..e0de107eff 100644
--- a/actionview/test/template/javascript_helper_test.rb
+++ b/actionview/test/template/javascript_helper_test.rb
@@ -29,11 +29,11 @@ class JavaScriptHelperTest < ActionView::TestCase
assert_equal "true", escape_javascript(true)
assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos'))
assert_equal %(backslash\\\\test), escape_javascript(%(backslash\\test))
- assert_equal %(dont <\\/close> tags), escape_javascript(%(dont tags))
+ assert_equal %(don\\'t <\\/close> tags), escape_javascript(%(don't tags))
assert_equal %(unicode
newline), escape_javascript((+%(unicode \342\200\250 newline)).force_encoding(Encoding::UTF_8).encode!)
assert_equal %(unicode
newline), escape_javascript((+%(unicode \342\200\251 newline)).force_encoding(Encoding::UTF_8).encode!)
- assert_equal %(dont <\\/close> tags), j(%(dont tags))
+ assert_equal %(don\\'t <\\/close> tags), j(%(don't tags))
end
def test_escape_backtick
diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb
index 5f7866490b..fb7dce4453 100644
--- a/actionview/test/template/url_helper_test.rb
+++ b/actionview/test/template/url_helper_test.rb
@@ -393,12 +393,12 @@ class UrlHelperTest < ActiveSupport::TestCase
link_to("Hello", "http://www.example.com", data: { confirm: "Are you sure?" })
)
assert_dom_equal(
- %{Hello},
- link_to("Hello", "http://www.example.com", data: { confirm: "You cant possibly be sure, can you?" })
+ %{Hello},
+ link_to("Hello", "http://www.example.com", data: { confirm: "You can't possibly be sure, can you?" })
)
assert_dom_equal(
- %{Hello},
- link_to("Hello", "http://www.example.com", data: { confirm: "You cant possibly be sure,\n can you?" })
+ %{Hello},
+ link_to("Hello", "http://www.example.com", data: { confirm: "You can't possibly be sure,\n can you?" })
)
end
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index c9cd96019f..1efa642c54 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -1,7 +1,7 @@
-* Cache and re-use generated attibute methods.
+* Cache and re-use generated attribute methods.
Generated methods with identical implementations will now share their instruction sequences
- leading to reduced memory retention, and sligtly faster load time.
+ leading to reduced memory retention, and slightly faster load time.
*Jean Boussier*
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index d8cfc24fd3..fea9e20059 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -29,7 +29,7 @@ module ActiveRecord
table_name[0...table_alias_length].tr(".", "_")
end
- # Returns the relation names useable to back Active Record models.
+ # Returns the relation names usable to back Active Record models.
# For most adapters this means all #tables and #views.
def data_sources
query_values(data_source_sql, "SCHEMA")
diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
index 9a4822aae5..d61f13d9f3 100644
--- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
@@ -996,7 +996,7 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_equal first_project.salaried_developers.size, preloaded_first_project.salaried_developers.size
end
- def test_has_and_belongs_to_many_is_useable_with_belongs_to_required_by_default
+ def test_has_and_belongs_to_many_is_usable_with_belongs_to_required_by_default
assert_difference "Project.first.developers_required_by_default.size", 1 do
Project.first.developers_required_by_default.create!(name: "Sean", salary: 50000)
end
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 0bd3d019f8..d998ae5b5d 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -1,7 +1,7 @@
* Deprecate `ActiveSupport::SafeBuffer`'s incorrect implicit conversion of objects into string.
Except for a few methods like `String#%`, objects must implement `#to_str`
- to be implictly converted to a String in string operations. In some
+ to be implicitly converted to a String in string operations. In some
circumstances `ActiveSupport::SafeBuffer` was incorrectly calling the
explicit conversion method (`#to_s`) on them. This behavior is now
deprecated.
diff --git a/codespell.txt b/codespell.txt
new file mode 100644
index 0000000000..64252f1f19
--- /dev/null
+++ b/codespell.txt
@@ -0,0 +1,43 @@
+ake
+alls
+ba
+cookoo
+coyp
+devels
+dum
+fase
+filetest
+fo
+fot
+froms
+frop
+hel
+inactivate
+isnt
+iterm
+januar
+mor
+nd
+ned
+noone
+objekt
+ot
+overthere
+reenable
+rouge
+searchin
+serie
+splitted
+supercalifragilisticexpialidoceous
+te
+tha
+thi
+ue
+unqiue
+upto
+varius
+vew
+vlaue
+wil
+wth
+yau
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md
index c240463fe4..51aded2ae1 100644
--- a/guides/source/contributing_to_ruby_on_rails.md
+++ b/guides/source/contributing_to_ruby_on_rails.md
@@ -275,9 +275,12 @@ Inspecting 1 file
For `rails-ujs` CoffeeScript and JavaScript files, you can run `npm run lint` in `actionview` folder.
-We are also running [misspell](https://github.com/client9/misspell) which is mainly written in Golang to check
-spelling with [GitHub Actions](../../.github/workflows/lint.yml). Correct commonly misspelled English words quickly
-with `misspell`. You can run `misspell` locally against all files with:
+#### 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/lint.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:
```bash
find . -type f | xargs ./misspell -i 'aircrafts,devels,invertions' -error
@@ -288,6 +291,14 @@ 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:
+
+```bash
+codespell --ignore-words=codespell.txt
+```
+
### Benchmark Your Code
For changes that might have an impact on performance, please benchmark your
diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb
index bff17eb0db..52927e7245 100644
--- a/railties/test/application/loading_test.rb
+++ b/railties/test/application/loading_test.rb
@@ -145,7 +145,7 @@ class LoadingTest < ActiveSupport::TestCase
assert_equal ["ActiveRecord::InternalMetadata", "ActiveRecord::SchemaMigration"], ActiveRecord::Base.descendants.collect(&:to_s).sort.uniq
end
- test "initialize cant be called twice" do
+ test "initialize can't be called twice" do
require "#{app_path}/config/environment"
assert_raise(RuntimeError) { Rails.application.initialize! }
end
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index a689f0d9d9..0e673d3647 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -276,13 +276,13 @@ class ActionsTest < Rails::Generators::TestCase
run_generator
action :environment do
- _ = "# This wont be added" # assignment to silence parse-time warning "unused literal ignored"
+ _ = "# This won't be added" # assignment to silence parse-time warning "unused literal ignored"
"# This will be added"
end
assert_file "config/application.rb" do |content|
assert_match(/# This will be added/, content)
- assert_no_match(/# This wont be added/, content)
+ assert_no_match(/# This won't be added/, content)
end
end