publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

Method publish has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def publish
    if logged_in_as(['admin', 'moderator'])
      @node = Node.find params[:id]
      if @node.status == 1
        flash[:notice] = 'Item already published.'
Severity: Minor
Found in app/controllers/admin_controller.rb - About 2 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 index has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    @toggle = params[:sort] || "uses"

    @title = I18n.t('tag_controller.tags')
    @paginated = true
Severity: Minor
Found in app/controllers/tag_controller.rb - About 2 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 edit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def edit
    @node = Node.find_by(nid: params[:id], type: 'note')

    if @node
      if current_user.uid == @node.uid || current_user.admin? || @node.has_tag("with:#{current_user.username}")
Severity: Minor
Found in app/controllers/notes_controller.rb - About 2 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 create has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    params[:name] ||= ''
    tagnames = params[:name].split(',')
    @output = {
      errors: [],
Severity: Major
Found in app/controllers/tag_controller.rb - About 2 hrs to fix

File openid_controller.rb has 259 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'pathname'

require 'openid'
require 'openid/consumer/discovery'
require 'openid/extensions/sreg'
Severity: Minor
Found in app/controllers/openid_controller.rb - About 2 hrs to fix

Method tagNearbyPeople has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def tagNearbyPeople(coordinates, tag, field, period = nil, sort_by = nil, order_direction = nil, limit = 10)
    raise("Must contain all four coordinates") if coordinates["nwlat"].nil?
    raise("Must contain all four coordinates") if coordinates["nwlng"].nil?
    raise("Must contain all four coordinates") if coordinates["selat"].nil?
    raise("Must contain all four coordinates") if coordinates["selng"].nil?
Severity: Major
Found in app/services/search_service.rb - About 2 hrs to fix

Class Revision has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class Revision < ApplicationRecord
  self.table_name = 'node_revisions'
  self.primary_key = 'vid'

  belongs_to :node, foreign_key: 'nid', counter_cache: :drupal_node_revisions_count
Severity: Minor
Found in app/models/revision.rb - About 2 hrs to fix

Method activity has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def activity
    blog = Tag.find_nodes_by_type('blog', 'note', 1).first
    # remove "classroom" postings; also switch to an EXCEPT operator in sql, see https://github.com/publiclab/plots2/issues/375
    hidden_nids = Node.hidden_response_node_ids
    notes = Node.where(type: 'note')
Severity: Major
Found in app/controllers/home_controller.rb - About 2 hrs to fix

Method replace has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def replace
    @node = Node.find(params[:id])
    if params[:before] && params[:after]
      # during round trip, strings are getting "\r\n" newlines converted to "\n",
      # so we're ensuring they remain "\r\n"; this may vary based on platform, unfortunately
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 2 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 get_node_from_urls_present has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def self.get_node_from_urls_present(urls)
    urls.each do |url|
      next unless url.include? "https://"

      if url.last == "."
Severity: Minor
Found in app/models/comment.rb - About 2 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 is_autoreply has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def self.is_autoreply(mail)
    autoreply = false
    autoreply = true if mail.header['Precedence'] && mail.header['Precedence'].value == "list"
    autoreply = true if mail.header['Precedence'] && mail.header['Precedence'].value == "junk"
    autoreply = true if mail.header['Precedence'] && mail.header['Precedence'].value == "bulk"
Severity: Minor
Found in app/models/comment.rb - About 2 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 create has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    return show_banned_flash unless current_user.status == User::Status::NORMAL

    saved, @node, @revision = new_note

Severity: Major
Found in app/controllers/notes_controller.rb - About 2 hrs to fix

Method multiple_add has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def multiple_add
    return_to = params[:return_to] || "/subscriptions?_=" + Time.now.to_i.to_s
    if params[:tagnames].blank?
      flash[:notice] = "Please enter tags for subscription in the url."
      redirect_to return_to
Severity: Major
Found in app/controllers/subscription_controller.rb - About 2 hrs to fix

Method create has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    @output = {
      errors: [],
      saved: []
    }
Severity: Minor
Found in app/controllers/user_tags_controller.rb - About 2 hrs to fix

Function graph has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function graph(data, el, labels) {

  el = el || "graph-canvas";
  data = data || [1, 2, 4, 1, 5];

Severity: Minor
Found in app/assets/javascripts/graph.js - About 1 hr to fix

Method methods has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def methods
    @nodes = Node.where(status: 1, type: %w(page))
      .where('term_data.name = ?', 'method')
      .includes(:revision, :tag)
      .references(:node_revision)
Severity: Minor
Found in app/controllers/wiki_controller.rb - About 1 hr to fix

Function contentLayerParser has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

   function contentLayerParser(map, markers_hash, map_tagname, limit) {
      var NWlat = map.getBounds().getNorthWest().lat ;
      var NWlng = map.getBounds().getNorthWest().lng ;
      var SElat = map.getBounds().getSouthEast().lat ;
      var SElng = map.getBounds().getSouthEast().lng ;
Severity: Minor
Found in app/assets/javascripts/leafletHelper.js - About 1 hr to fix

Method show has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    return if redirect_to_node_path?(@node)

    if @node
      if @node.has_power_tag('question') && @node.status == 1
Severity: Minor
Found in app/controllers/notes_controller.rb - About 1 hr to fix

Function getFileUploadOptions has 48 lines of code (exceeds 25 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 1 hr to fix

Method update has 48 lines of code (exceeds 25 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 1 hr to fix
Severity
Category
Status
Source
Language