mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #42132 from jbampton/fix-spelling
Add spell checking with codespell as a GitHub Action
This commit is contained in:
commit
daaa3b5868
14 changed files with 96 additions and 23 deletions
21
.github/workflows/lint.yml
vendored
21
.github/workflows/lint.yml
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 </close> tags))
|
||||
assert_equal %(don\\'t <\\/close> tags), escape_javascript(%(don't </close> 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 </close> tags))
|
||||
assert_equal %(don\\'t <\\/close> tags), j(%(don't </close> tags))
|
||||
end
|
||||
|
||||
def test_escape_backtick
|
||||
|
|
|
@ -393,12 +393,12 @@ class UrlHelperTest < ActiveSupport::TestCase
|
|||
link_to("Hello", "http://www.example.com", data: { confirm: "Are you sure?" })
|
||||
)
|
||||
assert_dom_equal(
|
||||
%{<a href="http://www.example.com" data-confirm="You cant possibly be sure, can you?">Hello</a>},
|
||||
link_to("Hello", "http://www.example.com", data: { confirm: "You cant possibly be sure, can you?" })
|
||||
%{<a href="http://www.example.com" data-confirm="You can't possibly be sure, can you?">Hello</a>},
|
||||
link_to("Hello", "http://www.example.com", data: { confirm: "You can't possibly be sure, can you?" })
|
||||
)
|
||||
assert_dom_equal(
|
||||
%{<a href="http://www.example.com" data-confirm="You cant possibly be sure,\n can you?">Hello</a>},
|
||||
link_to("Hello", "http://www.example.com", data: { confirm: "You cant possibly be sure,\n can you?" })
|
||||
%{<a href="http://www.example.com" data-confirm="You can't possibly be sure,\n can you?">Hello</a>},
|
||||
link_to("Hello", "http://www.example.com", data: { confirm: "You can't possibly be sure,\n can you?" })
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -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*
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
43
codespell.txt
Normal file
43
codespell.txt
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue