publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Avoid deeply nested control flow statements.
Open

              rescue ActiveRecord::RecordInvalid
                flash[:error] = tag.errors.full_messages
                redirect_to return_to
                return false
Severity: Major
Found in app/controllers/subscription_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            PasswordResetMailer.reset_notify(user, key).deliver_later unless user.nil? # respond the same to both successes and failures; security
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

              if current_user.crypted_password.nil? # the user has not created a pwd in the new site
                flash[:warning] = I18n.t('user_sessions_controller.create_password_for_new_site')
                redirect_to '/profile/edit'
              else
                flash[:notice] = I18n.t('user_sessions_controller.logged_in')
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Method map_data_string has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.map_data_string(lat, lon, tagname, template, mainLayer = nil)
Severity: Minor
Found in app/models/concerns/node_shared.rb - About 35 mins to fix

Method content_followed_in_period has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def content_followed_in_period(start_time, end_time,
    order_by = 'node_revisions.timestamp DESC', node_type = 'note', include_revisions = false)
Severity: Minor
Found in app/models/user.rb - About 35 mins to fix

Function notyNotification has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function notyNotification(theme, timeout, type, layout, text){
Severity: Minor
Found in app/assets/javascripts/notyNotification.js - About 35 mins to fix

Method notify has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def notify(current_user)
    if status == 4
      AdminMailer.notify_comment_moderators(self).deliver_later!(wait_until: 24.hours.from_now)
    else
      if parent.uid != current_user.uid && !UserTag.exists?(parent.uid, 'notify-comment-direct:false')
Severity: Minor
Found in app/models/comment.rb - About 35 mins to fix

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

Function makeDeepCopy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const makeDeepCopy = (input) => {
  let output, value, key;

  if (typeof input !== "object" || input === null || React.isValidElement) {
    return input;
Severity: Minor
Found in app/javascript/components/helpers.js - About 35 mins to fix

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 revision has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def revision
    @node = Node.find_wiki(params[:id])
    if @node
      @tags = @node.tags
      @tagnames = @tags.collect(&:name)
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 35 mins to fix

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 subscribers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.subscribers(tags)
    tids = tags.collect(&:tid)
    # include special tid for indiscriminant subscribers who want it all!
    all_tag = Tag.find_by(name: 'everything')
    tids += [all_tag.tid] if all_tag
Severity: Minor
Found in app/models/tag.rb - About 35 mins to fix

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 reset_user_password has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def reset_user_password
    if logged_in_as(['admin'])
      user = User.find(params[:id])
      if user
        key = user.generate_reset_key
Severity: Minor
Found in app/controllers/admin_controller.rb - About 35 mins to fix

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 wiki has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def wiki
    @node = Node.find_wiki(params[:id])

    if @node.blank? || @node.has_power_tag("lat").blank? || @node.has_power_tag("lon").blank?
      flash[:warning] = @node.blank? ? "Wiki page not found." : "No location found for wiki page."
Severity: Minor
Found in app/controllers/map_controller.rb - About 35 mins to fix

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 path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def path(size = :default)
    if is_image?
      if size == :thumb
        "/#{filepath.gsub('sites/default/files/', 'sites/default/files/imagecache/thumb/')}"
      elsif size == :default
Severity: Minor
Found in app/models/drupal_file.rb - About 35 mins to fix

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 new_comment_from_email has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.new_comment_from_email(mail)
    user = User.where(email: mail.from.first).first
    if user
      node_id = mail.subject[/#([\d]+)/, 1] # This tooks out the node ID from the subject line
      comment_id = mail.subject[/#c([\d]+)/, 1] # This tooks out the comment ID from the subject line if it exists
Severity: Minor
Found in app/models/comment.rb - About 35 mins to fix

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 change_locale has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def change_locale
    lang = params[:locale].to_s.strip.to_sym
    lang = I18n.default_locale unless I18n.available_locales.include?(lang)
    cookies.permanent[:plots2_locale] = lang
    I18n.locale = lang
Severity: Minor
Found in app/controllers/settings_controller.rb - About 35 mins to fix

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 order_string has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def order_string
    if params[:search] || @toggle == "uses"
      params[:order].blank? || (params[:order] == "desc") ? "count DESC" : "count ASC"
    else
      params[:order].blank? || (params[:order] == "desc") ? "name DESC" : "name ASC"
Severity: Minor
Found in app/controllers/tag_controller.rb - About 35 mins to fix

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 validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def validate(record)
    if record.title.blank?
      record.errors[:base] << "You must provide a title."
      # otherwise the below title uniqueness check fails, as title presence validation doesn't run until after
    elsif record.type == 'page'
Severity: Minor
Found in app/models/node.rb - About 25 mins to fix

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 delete_photo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def delete_photo
    @user = User.find_by(id: params[:id])
    if current_user.uid == @user.uid || current_user.admin?
      @user.photo = nil
      if @user.save!
Severity: Minor
Found in app/controllers/users_controller.rb - About 25 mins to fix

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 nodes_thumbnail_grid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.nodes_thumbnail_grid(body, _page = 1)
    body.gsub(/(?<![\>`])(\<p\>)?\[nodes\:grid\:(\S+)\]/) do |_tagname|
      tagname = Regexp.last_match(2)
      exclude = nil

Severity: Minor
Found in app/models/concerns/node_shared.rb - About 25 mins to fix

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 edit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def edit
    @revision = Revision.new
    @node = if params[:lang]
              Node.find_wiki(params[:lang] + '/' + params[:id])
            else
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 25 mins to fix

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

Severity
Category
Status
Source
Language