Block has too many lines. [138/25] Open
describe MarkupStylesController do
let(:super_admin) { build(:superadmin, id: 1, role_id: 5) }
let(:student) { build(:student, id: 1, role_id: 1) }
let(:student_role) { build(:role_of_student, id: 1, name: 'Student_role_test', description: '', parent_id: nil, default_page_id: nil) }
let(:instructor_role) { build(:role_of_instructor, id: 2, name: 'Instructor_role_test', description: '', parent_id: nil, default_page_id: nil) }
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Block has too many lines. [26/25] Open
describe '#update' do
context 'when markupstyle is updated successfully' do
it 'renders markupstyle#list' do
@params = {
id: 1,
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Similar blocks of code found in 3 locations. Consider refactoring. Open
describe '#action_allowed?' do
context 'when the current user is student' do
it 'returns false' do
stub_current_user(student, student.role.name, student.role)
expect(controller.send(:action_allowed?)).to be_falsey
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 64.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Trailing whitespace detected. Open
end
- Exclude checks
Trailing whitespace detected. Open
# This is to test the #new function which is called in the process of adding a new markup style.
- Exclude checks
Trailing whitespace detected. Open
end
- Exclude checks
Trailing whitespace detected. Open
stub_current_user(super_admin, super_admin.role.name, super_admin.role)
- Exclude checks
Missing space after #
. Open
#allow(MarkupStyle).to receive(:paginate).with(1,10).and_return(markup_style_list)
- Read upRead up
- Exclude checks
This cop checks whether comments have a leading space after the
#
denoting the start of the comment. The leading space is not
required for some RDoc special syntax, like #++
, #--
,
#:nodoc
, =begin
- and =end
comments, "shebang" directives,
or rackup options.
Example:
# bad
#Some comment
# good
# Some comment
Trailing whitespace detected. Open
# The test case is also to make sure other roles can not access the feature
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
expect(response).to render_template("markup_styles/new", "layouts/application")
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Final newline missing. Open
end
- Exclude checks
Trailing whitespace detected. Open
allow(MarkupStyle).to receive(:name).and_return('test markup_style') # Allowing MarkupStyle instance to receive :name
- Exclude checks
Trailing whitespace detected. Open
# This is the first action that takes place when the user tries to access the markup styles.
- Exclude checks
Trailing whitespace detected. Open
context 'when try to show a markupstyle' do
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
expect(response).to render_template("markup_styles/new", "layouts/application")
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
expect(response).to render_template("markup_styles/new", "layouts/application")
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Use 2 (not 4) spaces for indentation. Open
let(:super_admin) { build(:superadmin, id: 1, role_id: 5) }
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Space missing after comma. Open
let(:instructor) { build(:instructor, id: 2,role_id: 3) }
- Read upRead up
- Exclude checks
Checks for comma (,) not followed by some kind of space.
Example:
# bad
[1,2]
{ foo:bar,}
# good
[1, 2]
{ foo:bar, }
Trailing whitespace detected. Open
expect(assigns(:markup_styles)).not_to eq(nil)
- Exclude checks
Trailing whitespace detected. Open
expect(flash.now[:error]).to eq(nil) #
- Exclude checks
Trailing whitespace detected. Open
expect(response).to render_template("markup_styles/new", "layouts/application")
- Exclude checks
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
expect(response).to render_template("markup_styles/new", "layouts/application")
- Read upRead up
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Trailing whitespace detected. Open
post :create, params: @params
- Exclude checks
Trailing whitespace detected. Open
end
- Exclude checks
Trailing whitespace detected. Open
params = { page: '1' }
- Exclude checks
Trailing whitespace detected. Open
end
- Exclude checks
Trailing whitespace detected. Open
# The function checks whether the current user is authorized to access the feature.
- Exclude checks
Unnecessary spacing detected. Open
let(:instructor_role) { build(:role_of_instructor, id: 2, name: 'Instructor_role_test', description: '', parent_id: nil, default_page_id: nil) }
- Read upRead up
- Exclude checks
This cop checks for extra/unnecessary whitespace.
Example:
# good if AllowForAlignment is true
name = "RuboCop"
# Some comment and an empty line
website += "/bbatsov/rubocop" unless cond
puts "rubocop" if debug
# bad for any configuration
set_app("RuboCop")
website = "https://github.com/bbatsov/rubocop"
Trailing whitespace detected. Open
# expecting to render :show view properly
- Exclude checks
Extra empty line detected at block body end. Open
end
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of blocks match the configuration.
Example: EnforcedStyle: empty_lines
# good
foo do |bar|
# ...
end
Example: EnforcedStyle: noemptylines (default)
# good
foo do |bar|
# ...
end
Trailing whitespace detected. Open
# It is only available for those with super admin privileges.
- Exclude checks
Trailing whitespace detected. Open
# Testing the destroy feature, allowing to delete a markup style
- Exclude checks