publiclab/mapknitter

View on GitHub

Showing 52 of 127 total issues

Method profile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def profile
    params[:id] = current_user.login if logged_in? && params[:id].nil?
    @user = User.find_by(login: params[:id])
    @maps = Map.where(user_id: @user.id, status: Map::Status::NORMAL)
            .paginate(page: params[:page], per_page: 24)
Severity: Minor
Found in app/controllers/users_controller.rb - About 35 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 salt has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def Password.salt
    salt = ""
    64.times { salt << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
    salt
  end
Severity: Minor
Found in lib/password.rb - About 35 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    geojson = params[:annotation]

    respond_to do |format|
      format.json do
Severity: Minor
Found in app/controllers/annotations_controller.rb - About 25 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 javascript_include_tag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def javascript_include_tag(*sources)
      options = sources.extract_options!.stringify_keys
      debug   = options.key?(:debug) ? options.delete(:debug) : debug_assets?

      sources.map do |source|
Severity: Minor
Found in lib/extensions/action_view/helpers/asset_tag_helper.rb - About 25 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 _retrieveResources has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    _retrieveResources: function(id, callback) {
        /* 
         * With the optional id argument, _retrieveResources gets a single resource, if it exists. 
         * Without the optional id argument, _retrieveResources gets all resources.
         */
Severity: Minor
Found in app/assets/javascripts/mapknitter/core/Resources.js - About 25 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 archive has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def archive
    if logged_in? && current_user.can_delete?(@map)
      @map.archived = true
      @map.status = Map::Status::BANNED
      if @map.save
Severity: Minor
Found in app/controllers/maps_controller.rb - About 25 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 get_cm_per_pixel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def get_cm_per_pixel
    unless width.nil? || nodes == ''
      nodes = nodes_array
      # haversine might be more appropriate for large images
      scale = 20_037_508.34
Severity: Minor
Found in app/models/warpable.rb - About 25 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 cancel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def cancel
    @map = Map.find_by(id: params[:id])
    if @map.anonymous? || logged_in?
      export = @map.export
      export.status = 'none'
Severity: Minor
Found in app/controllers/export_controller.rb - About 25 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 poly_area has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def poly_area
    area = 0
    nodes = nodes_array
    nodes.each_with_index do |node, index|
      nextnode = if index < nodes.length - 1
Severity: Minor
Found in app/models/warpable.rb - About 25 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    if logged_in?
      @map = current_user.maps.new(map_params)
      @map.author = current_user.login # eventually deprecate
    else
Severity: Minor
Found in app/controllers/maps_controller.rb - About 25 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 extend has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

MapKnitter.Class.extend = function (obj) {
    var NewClass = function () {
        if (this.initialize) {
            this.initialize.apply(this, arguments);
        }
Severity: Minor
Found in app/assets/javascripts/mapknitter/core/Class.js - About 25 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 stylesheet_link_tag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def stylesheet_link_tag(*sources)
      options = sources.extract_options!.stringify_keys
      debug   = options.key?(:debug) ? options.delete(:debug) : debug_assets?

      sources.map do |source|
Severity: Minor
Found in lib/extensions/action_view/helpers/asset_tag_helper.rb - About 25 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