metamaps/metamaps

View on GitHub

Showing 2,044 of 2,044 total issues

Assignment Branch Condition size for embed_dat is too high. [64.66/16]
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 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. [63.7/16]
Open

  def update
    @user = User.find(current_user.id)

    if user_params[:password] == '' && user_params[:password_confirmation] == ''
      # not trying to change the password
Severity: Minor
Found in app/controllers/users_controller.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 relatives is too high. [59.92/16]
Open

  def relatives
    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 has too many lines. [51/10]
Open

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

    if term.present? && term.downcase[0..3] != 'map:' &&

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.

Function onDragMoveTopicHandler has 153 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  onDragMoveTopicHandler: function(node, eventInfo, e) {
    var self = JIT

    var authorized = Active.Map && Active.Map.authorizeToEdit(Active.Mapper)

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

Assignment Branch Condition size for synapses_csv is too high. [52.62/16]
Open

  def synapses_csv(output_format = 'array')
    output = []
    synapses.each do |synapse|
      if synapse.category == 'from-to'
        if synapse.topic1_id == id
Severity: Minor
Found in app/models/topic.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

File index.js has 392 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $ */

import SimpleWebRTC from 'simplewebrtc'
import SocketIoConnection from 'simplewebrtc/socketioconnection'

Severity: Minor
Found in frontend/src/Metamaps/Realtime/index.js - About 5 hrs to fix

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

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

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.

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

  static propTypes = {
    topicId: PropTypes.string,
    mapId: PropTypes.string,
    currentUser: PropTypes.object,
    map: PropTypes.object,
Severity: Major
Found in frontend/src/components/ContextMenu.js and 1 other location - About 5 hrs to fix
frontend/src/routes/App.js on lines 10..30

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

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

  static propTypes = {
    children: PropTypes.object,
    toast: PropTypes.string,
    unreadNotificationsCount: PropTypes.number,
    notifications: PropTypes.array,
Severity: Major
Found in frontend/src/routes/App.js and 1 other location - About 5 hrs to fix
frontend/src/components/ContextMenu.js on lines 7..27

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

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

Function startTypeahead has 129 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  startTypeahead: function() {
    var self = Search

    var mapheader = Active.Mapper ? '<div class="searchMapsHeader searchHeader"><h3 class="search-heading">Maps</h3><input type="checkbox" class="limitToMe" id="limitMapsToMe"></input><label for="limitMapsToMe" class="limitToMeLabel">added by me</label><div class="minimizeResults minimizeMapResults"></div><div class="clearfloat"></div></div>' : '<div class="searchMapsHeader searchHeader"><h3 class="search-heading">Maps</h3><div class="minimizeResults minimizeMapResults"></div><div class="clearfloat"></div></div>'
    var topicheader = Active.Mapper ? '<div class="searchTopicsHeader searchHeader"><h3 class="search-heading">Topics</h3><input type="checkbox" class="limitToMe" id="limitTopicsToMe"></input><label for="limitTopicsToMe" class="limitToMeLabel">added by me</label><div class="minimizeResults minimizeTopicResults"></div><div class="clearfloat"></div></div>' : '<div class="searchTopicsHeader searchHeader"><h3 class="search-heading">Topics</h3><div class="minimizeResults minimizeTopicResults"></div><div class="clearfloat"></div></div>'
Severity: Major
Found in frontend/src/Metamaps/GlobalUI/Search.js - About 5 hrs to fix

File Import.js has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $ */

import parse from 'csv-parse'
import _ from 'lodash'

Severity: Minor
Found in frontend/src/Metamaps/Import.js - About 5 hrs to fix

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

  def update
    @user = User.find(current_user.id)

    if user_params[:password] == '' && user_params[:password_confirmation] == ''
      # not trying to change the password
Severity: Minor
Found in app/controllers/users_controller.rb by rubocop

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.

File Control.js has 370 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import _ from 'lodash'
import outdent from 'outdent'

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

Assignment Branch Condition size for before_destroyed is too high. [43.21/16]
Open

  def before_destroyed
    if mappable.defer_to_map
      mappable.permission = mappable.defer_to_map.permission
      mappable.defer_to_map_id = nil
      mappable.save
Severity: Minor
Found in app/models/mapping.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

Function init has 120 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  init: function() {
    var self = this
    $(document).on('keydown', function(e) {
      if (!(Active.Map || Active.Topic)) return

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

File Create.js has 365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $, Hogan, Bloodhound */

import DataModel from './DataModel'
import Map from './Map'
import Mouse from './Mouse'
Severity: Minor
Found in frontend/src/Metamaps/Create.js - About 4 hrs to fix

Assignment Branch Condition size for user_metacodes is too high. [41.96/16]
Open

  def user_metacodes
    @m = current_user.settings.metacodes
    set = metacodeset
    @metacodes = if set && set == 'Most'
                   Metacode.where(id: current_user.most_used_metacodes).to_a
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

File index.js has 353 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $ */

import outdent from 'outdent'
import { find as _find } from 'lodash'
import { browserHistory } from 'react-router'
Severity: Minor
Found in frontend/src/Metamaps/Map/index.js - About 4 hrs to fix

Assignment Branch Condition size for after_created is too high. [40.1/16]
Open

  def after_created
    if mappable_type == 'Topic'
      ActionCable.server.broadcast 'map_' + map.id.to_s, type: 'topicAdded', topic: mappable.filtered, mapping_id: id
      meta = { 'x': xloc, 'y': yloc, 'mapping_id': id }
      Events::TopicAddedToMap.publish!(mappable, map, user, meta)
Severity: Minor
Found in app/models/mapping.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

Severity
Category
Status
Source
Language