lint
parent
2f8f719fc4
commit
5c3cc117a6
|
@ -1,6 +1,6 @@
|
|||
# This configuration was generated by
|
||||
# `rubocop --auto-gen-config`
|
||||
# on 2022-04-21 22:55:24 UTC using RuboCop version 1.28.1.
|
||||
# on 2022-05-18 01:29:38 UTC using RuboCop version 1.29.1.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
|
@ -13,12 +13,19 @@ Gemspec/RequiredRubyVersion:
|
|||
Exclude:
|
||||
- 'rating.gemspec'
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: AllowComments, AllowEmptyLambdas.
|
||||
Lint/EmptyBlock:
|
||||
Exclude:
|
||||
- 'spec/factories/global.rb'
|
||||
- 'spec/factories/toy.rb'
|
||||
- 'spec/support/db/migrate/create_globals_table.rb'
|
||||
- 'spec/support/db/migrate/create_toys_table.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
Layout/LineLength:
|
||||
Max: 139
|
||||
Lint/NoReturnInBeginEndBlocks:
|
||||
Exclude:
|
||||
- 'lib/rating/config.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe auto-correction (--auto-correct-all).
|
||||
|
@ -39,13 +46,24 @@ Metrics/ParameterLists:
|
|||
Max: 6
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
|
||||
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
|
||||
# SupportedStyles: snake_case, normalcase, non_integer
|
||||
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
|
||||
Naming/VariableNumber:
|
||||
Exclude:
|
||||
- 'spec/rails_helper.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: be, be_nil
|
||||
RSpec/BeNil:
|
||||
Exclude:
|
||||
- 'spec/models/extension/unscoped_rating_spec.rb'
|
||||
- 'spec/models/extension/where_spec.rb'
|
||||
- 'spec/models/rate/create_spec.rb'
|
||||
- 'spec/models/rate/rate_for_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: Prefixes.
|
||||
# Prefixes: when, with, without
|
||||
|
@ -84,11 +102,6 @@ RSpec/LetSetup:
|
|||
RSpec/MessageSpies:
|
||||
EnforcedStyle: receive
|
||||
|
||||
# Offense count: 2
|
||||
# Configuration parameters: AllowSubject.
|
||||
RSpec/MultipleMemoizedHelpers:
|
||||
Max: 12
|
||||
|
||||
# Offense count: 7
|
||||
# Configuration parameters: IgnoreSharedExamples.
|
||||
RSpec/NamedSubject:
|
||||
|
@ -111,16 +124,8 @@ Rails/ApplicationRecord:
|
|||
- 'lib/rating/models/rating/rating.rb'
|
||||
|
||||
# Offense count: 2
|
||||
# This cop supports unsafe auto-correction (--auto-correct-all).
|
||||
# Configuration parameters: Include.
|
||||
# Include: **/Rakefile, **/*.rake
|
||||
Rails/RakeEnvironment:
|
||||
Exclude:
|
||||
- 'Rakefile'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe auto-correction (--auto-correct).
|
||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
||||
# URISchemes: http, https
|
||||
Layout/LineLength:
|
||||
Max: 139
|
||||
Rails/RedundantPresenceValidationOnBelongsTo:
|
||||
Exclude:
|
||||
- 'lib/rating/models/rating/rate.rb'
|
||||
- 'lib/rating/models/rating/rating.rb'
|
||||
|
|
|
@ -93,8 +93,8 @@ module Rating
|
|||
resource_rating_avg = values.rating_avg
|
||||
resource_rating_count = values.rating_count.to_f
|
||||
|
||||
(resource_rating_count / (resource_rating_count + count_avg)) * resource_rating_avg +
|
||||
(count_avg / (resource_rating_count + count_avg)) * resource_type_rating_avg
|
||||
((resource_rating_count / (resource_rating_count + count_avg)) * resource_rating_avg) +
|
||||
((count_avg / (resource_rating_count + count_avg)) * resource_type_rating_avg)
|
||||
end
|
||||
|
||||
def execute_sql(sql)
|
||||
|
|
|
@ -10,11 +10,11 @@ RSpec.describe Rating::Extension, ':rated?' do
|
|||
before { author.rate resource, 1 }
|
||||
|
||||
context 'when has no rate for the given resource' do
|
||||
specify { expect(author.rated?(create(:article))).to eq false }
|
||||
it { expect(author.rated?(create(:article))).to be false }
|
||||
end
|
||||
|
||||
context 'when has rate for the given resource' do
|
||||
specify { expect(author.rated?(resource)).to eq true }
|
||||
it { expect(author.rated?(resource)).to be true }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -24,11 +24,11 @@ RSpec.describe Rating::Extension, ':rated?' do
|
|||
before { author.rate resource, 1, scope: category }
|
||||
|
||||
context 'when has no rate for the given resource' do
|
||||
specify { expect(author.rated?(resource, scope: create(:category))).to eq false }
|
||||
it { expect(author.rated?(resource, scope: create(:category))).to be false }
|
||||
end
|
||||
|
||||
context 'when has rate for the given resource' do
|
||||
specify { expect(author.rated?(resource, scope: category)).to eq true }
|
||||
it { expect(author.rated?(resource, scope: category)).to be true }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -37,11 +37,11 @@ RSpec.describe Rating::Extension, ':rated?' do
|
|||
before { author.rate resource, 1, extra_scopes: { scope_1: 'scope_1' } }
|
||||
|
||||
context 'when has no rate for the given resource with given extra scopes' do
|
||||
specify { expect(author.rated?(resource, extra_scopes: { scope_1: 'missing' })).to eq false }
|
||||
it { expect(author.rated?(resource, extra_scopes: { scope_1: 'missing' })).to be false }
|
||||
end
|
||||
|
||||
context 'when has rate for the given resource with given extra scopes' do
|
||||
specify { expect(author.rated?(resource, extra_scopes: { scope_1: 'scope_1' })).to eq true }
|
||||
it { expect(author.rated?(resource, extra_scopes: { scope_1: 'scope_1' })).to be true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ RSpec.describe Rating::Extension, 'unscoped_rating' do
|
|||
expect(rating.average.to_s).to eq '5.0'
|
||||
expect(rating.estimate.to_s).to eq '5.0'
|
||||
expect(rating.resource).to eq resource
|
||||
expect(rating.scopeable).to eq nil
|
||||
expect(rating.scopeable).to be(nil)
|
||||
expect(rating.sum).to eq 5
|
||||
expect(rating.total).to eq 1
|
||||
end
|
||||
|
@ -57,7 +57,7 @@ RSpec.describe Rating::Extension, 'unscoped_rating' do
|
|||
expect(rating.average.to_s).to eq '2.6666666666666667'
|
||||
expect(rating.estimate.to_s).to eq '2.6666666666666667'
|
||||
expect(rating.resource).to eq resource
|
||||
expect(rating.scopeable).to eq nil
|
||||
expect(rating.scopeable).to be(nil)
|
||||
expect(rating.sum).to eq 8
|
||||
expect(rating.total).to eq 3
|
||||
end
|
||||
|
@ -91,7 +91,7 @@ RSpec.describe Rating::Extension, 'unscoped_rating' do
|
|||
expect(rating.average.to_s).to eq '2.6666666666666667'
|
||||
expect(rating.estimate.to_s).to eq '2.6666666666666667'
|
||||
expect(rating.resource).to eq resource
|
||||
expect(rating.scopeable).to eq nil
|
||||
expect(rating.scopeable).to be(nil)
|
||||
expect(rating.sum).to eq 8
|
||||
expect(rating.total).to eq 3
|
||||
end
|
||||
|
|
|
@ -26,7 +26,7 @@ RSpec.describe Rating::Extension, 'unscoped_rating' do
|
|||
expect(rating.average.to_s).to eq '3.0'
|
||||
expect(rating.estimate.to_s).to eq '3.0'
|
||||
expect(rating.resource).to eq resource
|
||||
expect(rating.scopeable).to eq nil
|
||||
expect(rating.scopeable).to be(nil)
|
||||
expect(rating.sum).to eq 9
|
||||
expect(rating.total).to eq 3
|
||||
end
|
||||
|
|
|
@ -155,7 +155,7 @@ RSpec.describe Rating::Rate, ':create' do
|
|||
rate = described_class.last
|
||||
|
||||
expect(rate.author).to eq author
|
||||
expect(rate.comment).to eq nil
|
||||
expect(rate.comment).to be(nil)
|
||||
expect(rate.resource).to eq article
|
||||
expect(rate.value).to eq 3
|
||||
end
|
||||
|
@ -168,7 +168,7 @@ RSpec.describe Rating::Rate, ':create' do
|
|||
rate = described_class.last
|
||||
|
||||
expect(rate.author).to eq author
|
||||
expect(rate.comment).to eq nil
|
||||
expect(rate.comment).to be(nil)
|
||||
expect(rate.resource).to eq article
|
||||
expect(rate.value).to eq 3
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ RSpec.describe Rating::Rate, ':rate_for' do
|
|||
|
||||
context 'with no scopeable' do
|
||||
context 'when rate does not exist' do
|
||||
it { expect(described_class.rate_for(author: author, resource: article)).to eq nil }
|
||||
it { expect(described_class.rate_for(author: author, resource: article)).to be(nil) }
|
||||
end
|
||||
|
||||
context 'when rate exists' do
|
||||
|
@ -27,7 +27,7 @@ RSpec.describe Rating::Rate, ':rate_for' do
|
|||
|
||||
context 'when rate does not exist' do
|
||||
it do
|
||||
expect(described_class.rate_for(author: author, resource: article, scopeable: category)).to eq nil
|
||||
expect(described_class.rate_for(author: author, resource: article, scopeable: category)).to be(nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -99,7 +99,7 @@ RSpec.describe Rating::Rate, ':rate_for' do
|
|||
scopeable: category
|
||||
)
|
||||
|
||||
expect(result).to eq nil
|
||||
expect(result).to be(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue