metamaps/metamaps

View on GitHub

Showing 2,044 of 2,044 total issues

File Topic.js has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $ */

import $jit from '../patched/JIT'

import Active from './Active'
Severity: Minor
Found in frontend/src/Metamaps/Topic.js - About 4 hrs to fix

Function parseTabbedString has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parseTabbedString: function(text) {
    var self = Import

    // determine line ending and split lines
    var delim = '\n'
Severity: Major
Found in frontend/src/Metamaps/Import.js - About 4 hrs to fix

Assignment Branch Condition size for maps is too high. [39.92/16]
Open

  def maps
    term = params[:term]
    user = params[:user] ? params[:user] : nil

    if term.present? && term.downcase[0..5] != 'topic:' &&

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Function selectWithBox has 108 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  selectWithBox: function(e) {
    const self = this
    let sX = Mouse.boxStartCoordinates.x
    let sY = Mouse.boxStartCoordinates.y
    let eX = Mouse.boxEndCoordinates.x
Severity: Major
Found in frontend/src/Metamaps/JIT.js - About 4 hrs to fix

Assignment Branch Condition size for pagination_link_headers! is too high. [38.08/16]
Open

      def pagination_link_headers!(data)
        base_url = request.base_url + request.path
        old_query = request.query_parameters
        nxt = old_query.merge(page: data[:next_page]).map { |x| x.join('=') }.join('&')
        prev = old_query.merge(page: data[:prev_page]).map { |x| x.join('=') }.join('&')

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

JIT has 33 functions (exceeds 20 allowed). Consider refactoring.
Open

const JIT = {
  tempInit: false,
  tempNode: null,
  tempNode2: null,
  mouseDownPix: {},
Severity: Minor
Found in frontend/src/Metamaps/JIT.js - About 4 hrs to fix

Function renderTopic has 104 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderTopic: function(mapping, topic, createNewInDB, permitCreateSynapseAfter, opts = {}) {
    var nodeOnViz, tempPos

    var newnode = topic.createNode()

Severity: Major
Found in frontend/src/Metamaps/Topic.js - About 4 hrs to fix

Method has too many lines. [31/10]
Open

      def self.embed_dat
        embeddable.each_pair do |key, opts|
          is_plural = key.to_s.pluralize == key.to_s
          id_key = key.to_s.singularize + (is_plural ? '_ids' : '_id')
          serializer = opts.delete(:serializer) || "Api::V2::#{key.to_s.singularize.camelize}Serializer".constantize

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

Consider simplifying this complex logical expression.
Open

      if ((sX < x && x < eX && sY < y && y < eY) ||
        (sX > x && x > eX && sY > y && y > eY) ||
        (sX > x && x > eX && sY < y && y < eY) ||
        (sX < x && x < eX && sY > y && y > eY)) {
        if (e.shiftKey) {
Severity: Critical
Found in frontend/src/Metamaps/JIT.js - About 4 hrs to fix

File InfoBox.js has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $, Hogan, Bloodhound, Countable */

import outdent from 'outdent'
import { browserHistory } from 'react-router'

Severity: Minor
Found in frontend/src/Metamaps/Map/InfoBox.js - About 3 hrs to fix

Function arrange has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  arrange: function(layout, centerNode) {
    // first option for layout to implement is 'grid', will do an evenly spaced grid with its center at the 0,0 origin
    if (layout === 'grid') {
      const numNodes = _.size(Visualize.mGraph.graph.nodes) // this will always be an integer, the # of nodes on your graph visualization
      const numColumns = Math.floor(Math.sqrt(numNodes)) // the number of columns to make an even grid
Severity: Major
Found in frontend/src/Metamaps/Organize.js - About 3 hrs to fix

Assignment Branch Condition size for metacode_sets_json is too high. [34.13/16]
Open

  def metacode_sets_json
    metacode_sets = []
    metacode_sets << {
      name: 'Recently Used',
      metacodes: user_recent_metacodes
Severity: Minor
Found in app/helpers/metacodes_helper.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for decorate is too high. [34.91/16]
Open

    def decorate(notification, receipt)
      result = {
        id: notification.id,
        type: notification.notification_code,
        subject: notification.subject,

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method send_for_follows has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def self.send_for_follows(follows, entity, event_type, event)
    return if follows.empty?
    settings = get_settings_for_event(entity, event_type, event)
    # we'll prbly want to put the body into the actual loop so we can pass the current user in as a local
    body = renderer.render(template: settings[:template], locals: { entity: entity, event: event }, layout: false)
Severity: Minor
Found in app/services/notification_service.rb - About 3 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  onTopicFollow: topic => {
    const isFollowing = topic.isFollowedBy(Active.Mapper)
    $.post({
      url: `/topics/${topic.id}/${isFollowing ? 'un' : ''}follow`
    })
Severity: Major
Found in frontend/src/Metamaps/Topic.js and 1 other location - About 3 hrs to fix
frontend/src/Metamaps/Views/ExploreMaps.js on lines 138..151

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 144.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  onMapFollow: function(map) {
    const isFollowing = map.isFollowedBy(Active.Mapper)
    $.post({
      url: `/maps/${map.id}/${isFollowing ? 'un' : ''}follow`
    })
Severity: Major
Found in frontend/src/Metamaps/Views/ExploreMaps.js and 1 other location - About 3 hrs to fix
frontend/src/Metamaps/Topic.js on lines 90..103

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 144.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Assignment Branch Condition size for synapses is too high. [33.59/16]
Open

  def synapses
    term = params[:term]
    topic1id = params[:topic1id]
    topic2id = params[:topic2id]

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for update is too high. [33.56/16]
Open

  def update
    @metacode_set = MetacodeSet.find(params[:id])

    respond_to do |format|
      if @metacode_set.update_attributes(metacode_set_params)

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for relative_numbers is too high. [33.3/16]
Open

  def relative_numbers
    topics_already_has = params[:network] ? params[:network].split(',').map(&:to_i) : []

    alltopics = policy_scope(Topic.relatives(@topic.id, current_user)).to_a
    if params[:metacode].present?

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method topics has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def topics
    term = params[:term]
    user = params[:user] ? params[:user] : false

    if term.present? && term.downcase[0..3] != 'map:' &&
Severity: Minor
Found in app/controllers/search_controller.rb - About 3 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