metamaps/metamaps

View on GitHub

Showing 309 of 2,044 total issues

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

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

Function render has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { unreadNotificationsCount, currentUser, mobileTitle,
            mobileTitleWidth, onTitleClick, serverData } = this.props
    const { open } = this.state
    return <div>
Severity: Major
Found in frontend/src/components/MobileHeader.js - About 3 hrs to fix

Function passFilters has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  passFilters: function() {
    var self = Filter
    var visible = self.visible

    var passesMetacode, passesMapper, passesSynapse
Severity: Major
Found in frontend/src/Metamaps/Filter.js - About 3 hrs to fix

Method autocomplete_array_json has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def autocomplete_array_json(topics)
    topics.map do |t|
      is_map = t.is_a?(Map)
      metamap_metacode = Metacode.find_by(name: 'Metamap')
      {
Severity: Minor
Found in app/helpers/topics_helper.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

Assignment Branch Condition size for as_json is too high. [31.92/16]
Open

  def as_json(options = {})
    json = { id: id,
             name: name,
             image: image.url(:sixtyfour),
             admin: admin }
Severity: Minor
Found in app/models/user.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

Method has too many lines. [24/10]
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 if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for autocomplete_array_json is too high. [30.15/16]
Open

  def autocomplete_array_json(topics)
    topics.map do |t|
      is_map = t.is_a?(Map)
      metamap_metacode = Metacode.find_by(name: 'Metamap')
      {
Severity: Minor
Found in app/helpers/topics_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

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

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

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

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.

Method has too many lines. [24/10]
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 if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for send_for_follows is too high. [30.43/16]
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)

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 summarize_data has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.summarize_data(map, user, until_moment = DateTime.current)
    results = {
      stats: {}
    }

Severity: Major
Found in app/services/map_activity_service.rb - About 3 hrs to fix

Function renderTopic has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

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

    var newnode = topic.createNode()

Severity: Minor
Found in frontend/src/Metamaps/Topic.js - 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