Merge pull request #306 from crystal-ameba/Sija/fix-typos

Fix typos throughout the code
This commit is contained in:
Sijawusz Pur Rahnama 2022-11-16 18:42:22 +01:00 committed by GitHub
commit 243071700d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 26 deletions

View file

@ -127,7 +127,7 @@ module Ameba
config.sources.any?(&.fullpath.==(__FILE__)).should be_true config.sources.any?(&.fullpath.==(__FILE__)).should be_true
end end
it "returns a list of sources mathing globs" do it "returns a list of sources matching globs" do
config.globs = %w(**/config_spec.cr) config.globs = %w(**/config_spec.cr)
config.sources.size.should eq(1) config.sources.size.should eq(1)
end end

View file

@ -4,21 +4,21 @@ module Ameba::Rule::Lint
describe RedundantStringCoercion do describe RedundantStringCoercion do
subject = RedundantStringCoercion.new subject = RedundantStringCoercion.new
it "does not report if there is no redundant string coersion" do it "does not report if there is no redundant string coercion" do
s = Source.new %( s = Source.new %(
"Hello, #{name}" "Hello, #{name}"
) )
subject.catch(s).should be_valid subject.catch(s).should be_valid
end end
it "reports if there is a redundant string coersion" do it "reports if there is a redundant string coercion" do
s = Source.new %q( s = Source.new %q(
"Hello, #{name.to_s}" "Hello, #{name.to_s}"
) )
subject.catch(s).should_not be_valid subject.catch(s).should_not be_valid
end end
it "does not report if coersion is used in binary op" do it "does not report if coercion is used in binary op" do
s = Source.new %q( s = Source.new %q(
"Hello, #{3.to_s + 's'}" "Hello, #{3.to_s + 's'}"
) )

View file

@ -4,7 +4,7 @@ module Ameba::Rule::Lint
describe UselessAssign do describe UselessAssign do
subject = UselessAssign.new subject = UselessAssign.new
it "does not report used assigments" do it "does not report used assignments" do
s = Source.new %( s = Source.new %(
def method def method
a = 2 a = 2
@ -54,7 +54,7 @@ module Ameba::Rule::Lint
subject.catch(s).should_not be_valid subject.catch(s).should_not be_valid
end end
it "does not report ignored assigments" do it "does not report ignored assignments" do
s = Source.new %( s = Source.new %(
payload, _header = decode payload, _header = decode
puts payload puts payload
@ -859,7 +859,7 @@ module Ameba::Rule::Lint
end end
context "typeof" do context "typeof" do
it "reports useless assigments in typeof" do it "reports useless assignments in typeof" do
s = Source.new %( s = Source.new %(
typeof(begin typeof(begin
foo = 1 foo = 1
@ -944,7 +944,7 @@ module Ameba::Rule::Lint
subject.catch(s).should be_valid subject.catch(s).should be_valid
end end
it "doesn't report if assignement is referenced in for macro in exp" do it "doesn't report if assignment is referenced in for macro in exp" do
s = Source.new %( s = Source.new %(
foo = 22 foo = 22
@ -955,7 +955,7 @@ module Ameba::Rule::Lint
subject.catch(s).should be_valid subject.catch(s).should be_valid
end end
it "doesn't report if assignement is referenced in for macro in body" do it "doesn't report if assignment is referenced in for macro in body" do
s = Source.new %( s = Source.new %(
foo = 22 foo = 22
@ -966,7 +966,7 @@ module Ameba::Rule::Lint
subject.catch(s).should be_valid subject.catch(s).should be_valid
end end
it "doesn't report if assignement is referenced in if macro in cond" do it "doesn't report if assignment is referenced in if macro in cond" do
s = Source.new %( s = Source.new %(
foo = 22 foo = 22
{% if "foo".id %} {% if "foo".id %}
@ -975,7 +975,7 @@ module Ameba::Rule::Lint
subject.catch(s).should be_valid subject.catch(s).should be_valid
end end
it "doesn't report if assignement is referenced in if macro in then" do it "doesn't report if assignment is referenced in if macro in then" do
s = Source.new %( s = Source.new %(
foo = 22 foo = 22
{% if true %} {% if true %}
@ -985,7 +985,7 @@ module Ameba::Rule::Lint
subject.catch(s).should be_valid subject.catch(s).should be_valid
end end
it "doesn't report if assignement is referenced in if macro in else" do it "doesn't report if assignment is referenced in if macro in else" do
s = Source.new %( s = Source.new %(
foo = 22 foo = 22
{% if true %} {% if true %}

View file

@ -146,7 +146,7 @@ module Ameba::Rule::Style
end end
end end
context "expception handler" do context "exception handler" do
it "doesn't report if there is no redundant next in exception handler" do it "doesn't report if there is no redundant next in exception handler" do
expect_no_issues subject, <<-CRYSTAL expect_no_issues subject, <<-CRYSTAL
block do |v| block do |v|

View file

@ -41,7 +41,7 @@ module Ameba
end end
end end
struct SeverityConvertable struct SeverityConvertible
include YAML::Serializable include YAML::Serializable
@[YAML::Field(converter: Ameba::SeverityYamlConverter)] @[YAML::Field(converter: Ameba::SeverityYamlConverter)]
@ -52,33 +52,33 @@ module Ameba
describe ".from_yaml" do describe ".from_yaml" do
it "converts from yaml to Severity::Error" do it "converts from yaml to Severity::Error" do
yaml = {severity: "error"}.to_yaml yaml = {severity: "error"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml) converted = SeverityConvertible.from_yaml(yaml)
converted.severity.should eq Severity::Error converted.severity.should eq Severity::Error
end end
it "converts from yaml to Severity::Warning" do it "converts from yaml to Severity::Warning" do
yaml = {severity: "warning"}.to_yaml yaml = {severity: "warning"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml) converted = SeverityConvertible.from_yaml(yaml)
converted.severity.should eq Severity::Warning converted.severity.should eq Severity::Warning
end end
it "converts from yaml to Severity::Convention" do it "converts from yaml to Severity::Convention" do
yaml = {severity: "convention"}.to_yaml yaml = {severity: "convention"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml) converted = SeverityConvertible.from_yaml(yaml)
converted.severity.should eq Severity::Convention converted.severity.should eq Severity::Convention
end end
it "raises if severity is not a scalar" do it "raises if severity is not a scalar" do
yaml = {severity: {convention: true}}.to_yaml yaml = {severity: {convention: true}}.to_yaml
expect_raises(Exception, "Severity must be a scalar") do expect_raises(Exception, "Severity must be a scalar") do
SeverityConvertable.from_yaml(yaml) SeverityConvertible.from_yaml(yaml)
end end
end end
it "raises if severity has a wrong type" do it "raises if severity has a wrong type" do
yaml = {severity: [1, 2, 3]}.to_yaml yaml = {severity: [1, 2, 3]}.to_yaml
expect_raises(Exception, "Severity must be a scalar") do expect_raises(Exception, "Severity must be a scalar") do
SeverityConvertable.from_yaml(yaml) SeverityConvertible.from_yaml(yaml)
end end
end end
end end
@ -86,19 +86,19 @@ module Ameba
describe ".to_yaml" do describe ".to_yaml" do
it "converts Severity::Error to yaml" do it "converts Severity::Error to yaml" do
yaml = {severity: "error"}.to_yaml yaml = {severity: "error"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml).to_yaml converted = SeverityConvertible.from_yaml(yaml).to_yaml
converted.should eq "---\nseverity: Error\n" converted.should eq "---\nseverity: Error\n"
end end
it "converts Severity::Warning to yaml" do it "converts Severity::Warning to yaml" do
yaml = {severity: "warning"}.to_yaml yaml = {severity: "warning"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml).to_yaml converted = SeverityConvertible.from_yaml(yaml).to_yaml
converted.should eq "---\nseverity: Warning\n" converted.should eq "---\nseverity: Warning\n"
end end
it "converts Severity::Convention to yaml" do it "converts Severity::Convention to yaml" do
yaml = {severity: "convention"}.to_yaml yaml = {severity: "convention"}.to_yaml
converted = SeverityConvertable.from_yaml(yaml).to_yaml converted = SeverityConvertible.from_yaml(yaml).to_yaml
converted.should eq "---\nseverity: Convention\n" converted.should eq "---\nseverity: Convention\n"
end end
end end

View file

@ -117,7 +117,7 @@ module Ameba::AST
!!outer_scope.try(&.in_macro?) !!outer_scope.try(&.in_macro?)
end end
# Returns `true` if instance variable is assinged in this scope. # Returns `true` if instance variable is assigned in this scope.
def assigns_ivar?(name) def assigns_ivar?(name)
arguments.find(&.name.== name) && arguments.find(&.name.== name) &&
ivariables.find(&.name.== "@#{name}") ivariables.find(&.name.== "@#{name}")

View file

@ -40,7 +40,7 @@ module Ameba::Rule::Lint
# during iterations. So it reports the issue on the first sample and passes on # during iterations. So it reports the issue on the first sample and passes on
# the second one. # the second one.
# #
# There are also other technics to solve the problem above which are # There are also other techniques to solve the problem above which are
# [officially documented](https://crystal-lang.org/reference/guides/concurrency.html) # [officially documented](https://crystal-lang.org/reference/guides/concurrency.html)
# #
# YAML configuration example: # YAML configuration example:

View file

@ -12,7 +12,7 @@ module Ameba::Rule::Style
# And should be rewritten to the following: # And should be rewritten to the following:
# #
# ``` # ```
# if s.emtpy? # if s.empty?
# :ok # :ok
# end # end
# ``` # ```

View file

@ -90,7 +90,7 @@ module Ameba::Rule::Style
# ``` # ```
# Style/RedundantReturn: # Style/RedundantReturn:
# Enabled: true # Enabled: true
# AllowMutliReturn: true # AllowMultiReturn: true
# AllowEmptyReturn: true # AllowEmptyReturn: true
# ``` # ```
class RedundantReturn < Base class RedundantReturn < Base