publiclab/plots2

View on GitHub

Showing 585 of 588 total issues

File node.rb has 796 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class UniqueUrlValidator < ActiveModel::Validator
  def validate(record)
    if record.title == '' || record.title.nil?
      # record.errors[:base] << "You must provide a title."
      # otherwise the below title uniqueness check fails, as title presence validation doesn't run until after
Severity: Major
Found in app/models/node.rb - About 1 day to fix

Class Node has 95 methods (exceeds 20 allowed). Consider refactoring.
Open

class Node < ActiveRecord::Base
  include NodeShared # common methods for node-like models

  self.table_name = 'node'
  self.primary_key = 'nid'
Severity: Major
Found in app/models/node.rb - About 1 day to fix

Module has too many lines. [347/303]
Open

module NodeShared
  extend ActiveSupport::Concern

  def likes
    cached_likes
Severity: Minor
Found in app/models/concerns/node_shared.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Function prototype has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

Searcher.prototype = new function() {
  // search is performed in chunks of 1000 for non-blocking user input
  var CHUNK_SIZE = 1000;
  // do not try to find more than 100 results
  var MAX_RESULTS = 100;
Severity: Minor
Found in doc/app/js/searcher.js - About 1 day 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 handle_site_login_flow has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

  def handle_site_login_flow
    username = params[:user_session][:username] if params[:user_session]
    u = User.find_by(username: username)
    if u && u.password_checker != 0
      n = u.password_checker
Severity: Minor
Found in app/controllers/user_sessions_controller.rb - About 1 day 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

Class User has 62 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base
  extend Utils
  include Statistics
  self.table_name = 'rusers'
  alias_attribute :name, :username
Severity: Major
Found in app/models/user.rb - About 1 day to fix

Method can_tag has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

  def can_tag(tagname, user, errors = false)
    if tagname[0..4] == 'with:'
      if User.find_by_username_case_insensitive(tagname.split(':')[1]).nil?
        errors ? I18n.t('node.cannot_find_username') : false
      elsif author.uid != user.uid
Severity: Minor
Found in app/models/node.rb - About 1 day 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

File tag_controller.rb has 456 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class TagController < ApplicationController
  respond_to :html, :xml, :json, :ics
  before_action :require_user, only: %i(create delete add_parent)

  def index
Severity: Minor
Found in app/controllers/tag_controller.rb - About 6 hrs to fix

Method create has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    if current_user.status == 1
      saved, @node, @revision = Node.new_note(uid: current_user.uid,
                                              title: params[:title],
                                              body: params[:body],
Severity: Minor
Found in app/controllers/notes_controller.rb - About 6 hrs 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 prototype has 160 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Searcher.prototype = new function() {
  // search is performed in chunks of 1000 for non-blocking user input
  var CHUNK_SIZE = 1000;
  // do not try to find more than 100 results
  var MAX_RESULTS = 100;
Severity: Major
Found in doc/app/js/searcher.js - About 6 hrs to fix

Method index has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    begin
      permitted_params = params.permit(
        'authenticity_token', 'back_to',
        'commit',
Severity: Minor
Found in app/controllers/openid_controller.rb - About 6 hrs 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 show has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    # try for a matching /wiki/_TAGNAME_ or /_TAGNAME_
    @wiki = Node.where(path: "/wiki/#{params[:id]}").try(:first) || Node.where(path: "/#{params[:id]}").try(:first)
    @wiki = Node.where(slug: @wiki.power_tag('redirect'))&.first if @wiki&.has_power_tag('redirect') # use a redirected wiki page if it exists

Severity: Minor
Found in app/controllers/tag_controller.rb - About 6 hrs 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 show has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @node = if params[:lang]
              Node.find_wiki(params[:lang] + '/' + params[:id])
            else
              Node.find_wiki(params[:id])
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 6 hrs 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

File wiki_controller.rb has 406 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'rss'

class WikiController < ApplicationController
  before_action :require_user, only: %i(new create edit update delete replace)

Severity: Minor
Found in app/controllers/wiki_controller.rb - About 5 hrs to fix

Method add_tag has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

  def add_tag(tagname, user)
    tagname = tagname.downcase
    unless has_tag_without_aliasing(tagname)
      saved = false
      table_updated = false
Severity: Minor
Found in app/models/node.rb - About 5 hrs 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 addGrid has 132 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function addGrid(map)
 {
   // A function to return the style of a cell
   function create_cell_style(fill) {
   return {
Severity: Major
Found in app/assets/javascripts/locationForm.js - About 5 hrs to fix

Method multiple_add has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  def multiple_add
    if !params[:tagnames] || params[:tagnames] == ''
      flash[:notice] = "Please enter tags for subscription in the url."
      redirect_to "/subscriptions" + "?_=" + Time.now.to_i.to_s
      return
Severity: Minor
Found in app/controllers/subscription_controller.rb - About 5 hrs 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 error_messages_for has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

      def error_messages_for(*params)
        options = params.extract_options!.symbolize_keys

        objects = Array.wrap(options.delete(:object) || params).map do |object|
          object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
Severity: Minor
Found in lib/dynamic_form/action_view/helpers/dynamic_form.rb - About 5 hrs 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 setupLEL has 130 lines of code (exceeds 25 allowed). Consider refactoring.
Open

   function setupLEL(map , sethash){ 

    var baselayer = L.tileLayer('https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png', {
                attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map) ; 
Severity: Major
Found in app/assets/javascripts/leaflet_helper.js - About 5 hrs to fix

Method update has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    @node = Node.find(params[:id])
    if current_user.uid == @node.uid || current_user.admin? || @node.has_tag("with:#{current_user.username}")
      @revision = @node.latest
      @revision.title = params[:title]
Severity: Minor
Found in app/controllers/notes_controller.rb - About 5 hrs 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