publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Method smtp_test has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def smtp_test
    require 'socket'

    s = TCPSocket.new ActionMailer::Base.smtp_settings[:address], ActionMailer::Base.smtp_settings[:port]

Severity: Minor
Found in app/controllers/admin_controller.rb - About 45 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    if !current_user.admin?
      flash[:warning] = 'Only admins may edit features.'
      redirect_to "/features?_=#{Time.now.to_i}"
    else
Severity: Minor
Found in app/controllers/features_controller.rb - About 45 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

Avoid deeply nested control flow statements.
Open

        errors ? I18n.t('node.cannot_add_yourself_coauthor') : false
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Method useremail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def useremail 
   if logged_in_as(['admin', 'moderator']) 
     if params[:address] 
       # address was submitted. find the username(s) and return. 
       @address = params[:address] 
Severity: Minor
Found in app/controllers/admin_controller.rb - About 45 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 add_comment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def add_comment(params = {})
    thread = !comments.empty? && !comments.last.nil? && !comments.last.thread.nil? ? comments.last.next_thread : '01/'
    comment_via_status = params[:comment_via].nil? ? 0 : params[:comment_via].to_i
    user = User.find(params[:uid])
    status = user.first_time_poster && user.first_time_commenter ? 4 : 1
Severity: Minor
Found in app/models/node.rb - About 45 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 revisions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def revisions
    @node = Node.find_wiki(params[:id])
    if @node
      @revisions = @node.revisions
      @pagy_revisions, @revisions = pagy(@revisions.where(status: 1), items: 20) unless current_user&.can_moderate?
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 45 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

Avoid deeply nested control flow statements.
Open

              unless tag.subscriptions.empty? || isStatusValid || !isMonthOld
                SubscriptionMailer.notify_tag_added(self, tag, user).deliver_later
              end
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Method update_node_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def update_node_attributes
    ActiveRecord::Base.transaction do
      @node.vid = @revision.vid
      @node.title = @revision.title

Severity: Minor
Found in app/controllers/wiki_controller.rb - About 45 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

Avoid deeply nested control flow statements.
Open

              rescue StandardError
                return [false, tag.destroy]
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

      errors ? I18n.t('node.only_admins_can_lock') : false
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Method rich has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def rich
    if params[:main_image] && Image.find_by(id: params[:main_image])
      @main_image = Image.find_by(id: params[:main_image]).path
    end

Severity: Minor
Found in app/controllers/editor_controller.rb - About 45 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

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

Method tagNearbyNodes has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def tagNearbyNodes(coordinates, tag, period = { "from" => nil, "to" => nil }, sort_by = nil, order_direction = nil, limit = 10)
Severity: Minor
Found in app/services/search_service.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                tagnames = params[:tagnames].class == Array ? params[:tagnames].join(', ') : params[:tagnames]
Severity: Major
Found in app/controllers/subscription_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if session[:openid_return_to] # for openid login, redirects back to openid auth process
              return_to = session[:openid_return_to]
              session[:openid_return_to] = nil
              redirect_to return_to + hash_params
            elsif params[:return_to] && params[:return_to].split('/')[0..3] == ["", "subscribe", "multiple", "tag"]
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

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

            if session[:openid_return_to] # for openid login, redirects back to openid auth process
              return_to = session[:openid_return_to]
              session[:openid_return_to] = nil
              redirect_to return_to + hash_params
            else
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            params[:user_session][:openid_identifier] = 'https://old.publiclab.org/people/' + username + '/identity' if username
Severity: Major
Found in app/controllers/user_sessions_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            render json: { status: status, message: message, id: tag.tid, tagname: params[:name], url: "/tags" + "?_=" + Time.now.to_i.to_s } if current_user
Severity: Major
Found in app/controllers/subscription_controller.rb - About 45 mins to fix

Method decision has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def decision
    oidreq = session[:last_oidreq]
    session[:last_oidreq] = nil
    id_to_send = params[:id_to_send]
    identity = oidreq&.identity
Severity: Minor
Found in app/controllers/openid_controller.rb - About 45 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