publiclab/plots2

View on GitHub

Showing 216 of 688 total issues

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

  def new
    @revision = Revision.new
    if current_user &.first_time_poster
      flash[:notice] = "You can create a wiki once your research note/question has been approved by moderators. Click <a href='https://publiclab.org/notes/tester/04-23-2016/new-moderation-system-for-first-time-posters'>here</a> to learn why."
      redirect_to '/'
Severity: Minor
Found in app/controllers/wiki_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

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

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

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

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

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

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

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

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 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 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 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 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

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

            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

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
Severity
Category
Status
Source
Language