metamaps/metamaps

View on GitHub

Showing 183 of 2,002 total issues

File JIT.js has 1330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global $, Image */

import _ from 'lodash'
import clipboard from 'clipboard-js'

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

Function onDragMoveTopicHandler has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

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

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

Severity: Minor
Found in frontend/src/Metamaps/JIT.js - About 1 day 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 Controller has 199 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    var Controller = function(container, images, options)
    {                        
        var    items = [], funcSin = Math.sin, funcCos = Math.cos, ctx=this;
        this.controlTimer = 0;
        this.stopped = false;
Severity: Major
Found in app/assets/javascripts/cloudcarousel-secret.js - About 7 hrs to fix

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

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

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

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

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

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

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

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

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

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

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

Severity
Category
Status
Source
Language