publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Method photo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def photo
    @user = User.find_by(id: params[:uid])
    if current_user.uid == @user.uid || current_user.admin?
      @user.photo = params[:photo]
      if @user.save!
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr 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 sortGrid has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function sortGrid(type, selector, headerLink) {

  var table = $(selector),
      headerLink = $(headerLink),
      desc = headerLink.hasClass('desc'),
Severity: Minor
Found in app/assets/javascripts/grids.js - About 1 hr to fix

Function show_list has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var show_list = function (list) {

    $.get(lists[list].feed, function (feed) {
 
      $('.lists').html('');
Severity: Minor
Found in app/assets/javascripts/dashboard.js - About 1 hr to fix

Function inWords has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    self.inWords = function(timeAgo) {

      var seconds = Math.floor((new Date() - new Date(timeAgo)) / 1000),
          separator = this.locales.separator || ' ',
          words = this.locales.prefix + separator,
Severity: Minor
Found in app/assets/javascripts/timeago.js - About 1 hr to fix

Method nodes_by_tagname has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.nodes_by_tagname(tagname, type, limit: 24)
    if type.is_a? Array
      type1 = type.first
      type2 = type.last
      pinned = pinned_nodes(tagname)
Severity: Minor
Found in app/models/concerns/node_shared.rb - About 1 hr to fix

Method like has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.like(nid, user)
    # scope like variable outside the transaction
    like = nil
    count = nil

Severity: Minor
Found in app/models/node.rb - About 1 hr to fix

Method decision has 27 lines of code (exceeds 25 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 1 hr to fix

Function addGrid has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function addGrid(map)
 {
   // A function to return the style of a cell
   function create_cell_style(fill) {
   return {
Severity: Minor
Found in app/assets/javascripts/locationForm.js - About 55 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 mark_spam_revision has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def mark_spam_revision
    @revision = Revision.find_by(vid: params[:vid])
    @node = Node.find_by(nid: @revision.nid)

    if @node.revisions.size <= 1
Severity: Minor
Found in app/controllers/admin_controller.rb - About 55 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 getFileUploadOptions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function getFileUploadOptions(dropZone, isSmallDropzone = false) {
  return {
    url: "/images",
    paramName: "image[photo]",
    dropZone: isSmallDropzone ? null : dropZone,
Severity: Minor
Found in app/assets/javascripts/editorToolbar.js - About 55 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 mark_spam has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def mark_spam
    @node = Node.find params[:id]
    if logged_in_as(['admin', 'moderator'])
      if @node.status == 1 || @node.status == 4
        @node.spam
Severity: Minor
Found in app/controllers/admin_controller.rb - About 55 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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def delete
    # assume tag, for now
    if params[:type] == "tag"
      id = Tag.find_by(name: params[:name]).tid
    end
Severity: Minor
Found in app/controllers/subscription_controller.rb - About 55 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 shortlink has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def shortlink
    size = params[:size] || params[:s]
    size ||= :large
    size = :thumb if size.to_s == 't'
    size = :thumb if size.to_s == 'thumbnail'
Severity: Minor
Found in app/controllers/images_controller.rb - About 55 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 notify_tag_added has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def notify_tag_added(node, tag, tagging_user)
    subject = '[PublicLab] ' +
              (node.has_power_tag('question') ? 'Question: ' : '') +
              node.title +
              " (##{node.id}) "
Severity: Minor
Found in app/mailers/subscription_mailer.rb - About 55 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 tagNearbyPeople has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def tagNearbyPeople(coordinates, tag, field, period = nil, sort_by = nil, order_direction = nil, limit = 10)
Severity: Major
Found in app/services/search_service.rb - About 50 mins to fix

Avoid deeply nested control flow statements.
Open

    elsif tagname == 'blog' && user.basic_user?
      errors ? 'Only moderators or admins can use this tag.' : false
    elsif tagname.split(':')[0] == 'redirect' && Node.where(slug: one_split).size <= 0
      errors ? I18n.t('node.page_does_not_exist') : false
    elsif socials[one_split&.to_sym].present?
Severity: Major
Found in app/models/node.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

        elsif current_user.can_moderate?
          flash.now[:warning] = "Only moderators and admins see this page, as it is redirected to #{Node.find(@node.power_tag('abtest')).title} roughly around 50% of the time.
        To remove this behavior, delete the tag beginning with 'abtest:'"
Severity: Major
Found in app/controllers/wiki_controller.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            if @user.changed? && @user.save
              flash[:notice] = I18n.t('users_controller.password_change_success')
              @user.password_checker = 0
              @user.save
              redirect_to "/dashboard"
Severity: Major
Found in app/controllers/users_controller.rb - About 45 mins to fix

Function displayMapContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

   function displayMapContent(map, markers_hash, mainContent, limit) {
      if(typeof mainContent !== "undefined" && mainContent !== ""){
         if (mainContent === "people") {
           map.on('load viewreset resize zoomend moveend', debounce(peopleMap, 400));
           setTimeout(peopleMap,0); // to ensure fetch on initial page load
Severity: Minor
Found in app/assets/javascripts/leafletHelper.js - 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

          if Random.rand(2) == 0
            redirect_to Node.find(@node.power_tag('abtest')).path
            return
          end
Severity: Major
Found in app/controllers/wiki_controller.rb - About 45 mins to fix
Severity
Category
Status
Source
Language