Showing 117 of 792 total issues
Method has too many lines. [8/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
def bootstrap_class_for flash_type
case flash_type
when 'warning'
'alert-warning'
when 'notice', 'success'
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [8/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
def show
url = 'https://api.github.com/repos/AgileVentures/LocalSupport/contributors'
uri = URI.parse url
request = Net::HTTP::Get.new(uri.request_uri)
http = Net::HTTP.new(uri.host, uri.port)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [8/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
def destroy
user = User.find(params[:id])
if user == current_user
flash[:error] = "You may not destroy your own account!"
else
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [8/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
def <=> other
if (@sym == :what_they_do && other.sym == :how_they_help) || (@sym == :what_they_do && other.sym == :who_they_help) ||
(@sym == :who_they_help && other.sym == :how_they_help)
-1
elsif @sym == other.sym
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [8/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
def self.build params
params.permit(
:id,
:email,
:password,
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [8/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
def find_or_create_charities_and_update
@charities.each do |charity|
organisation = @model_klass.find_or_create_by! name: charity['name'].titleize
organisation.update ({ address: charity['add1'],
postcode: charity['postcode'],
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [8/7] (https://github.com/bbatsov/ruby-style-guide#short-methods) Open
def index
index_instance_vars_from_params
index_services_and_markers
response.headers.delete 'X-Frame-Options'
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for type is too high. [15.3/15] (http://c2.com/cgi/wiki?AbcMetric) Open
def type
return CategoryType.what_they_do if self.charity_commission_id < 200
return CategoryType.who_they_help if (self.charity_commission_id < 300) & (self.charity_commission_id > 199)
return CategoryType.how_they_help if (self.charity_commission_id < 400) & (self.charity_commission_id > 299)
end
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Function invite_users
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.fn.invite_users = function () {
$(this).click(function () {
var values = {},
checks = $('input:checked');
checks.each(function () {
Method <=>
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def <=> other
if (@sym == :what_they_do && other.sym == :how_they_help) || (@sym == :what_they_do && other.sym == :who_they_help) ||
(@sym == :who_they_help && other.sym == :how_they_help)
-1
elsif @sym == other.sym
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
if (@sym == :what_they_do && other.sym == :how_they_help) || (@sym == :what_they_do && other.sym == :who_they_help) ||
(@sym == :who_they_help && other.sym == :how_they_help)
-1
elsif @sym == other.sym
0
Method with
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.with(listener, params, model_klass = ProposedOrganisationEdit, user_klass = User, mailer_klass = AdminMailer)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(listener, params, model_klass, user_klass, mailer_klass)
Method create_and_validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.create_and_validate(attributes)
# create!(attributes.select{|k,v| !v.nil?})
create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method render_error
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def render_error(status, error)
raise error unless Rails.env.production?
Rails.logger.error error.message
error.backtrace.each_with_index { |line, index| Rails.logger.error line; break if index >= 5 }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show
render template: 'pages/404', status: 404 and return if @organisation.nil?
organisations = Organisation.where(id: @organisation.id)
@user_opts = current_user ? get_user_options(@organisation) : { grabbable: true }
@user_opts[:can_propose_edits] = current_user.present? && !@user_opts[:editable]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method build_map_markers
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def build_map_markers(organisations)
::MapMarkerJson.build(organisations) do |org, marker|
marker.lat org.latitude
marker.lng org.longitude
marker.infowindow render_to_string(partial: 'organisations/popup', locals: {org: org})
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Don't use IDs in selectors. Open
#footer a {
- Exclude checks
Don't use IDs in selectors. Open
#error_explanation h4 {
- Exclude checks
Use of !important Open
background-color: whitesmoke !important;
- Exclude checks