metamaps/metamaps

View on GitHub

Showing 309 of 2,044 total issues

Consider simplifying this complex logical expression.
Open

      if (testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testX <= maxBoxX) {
        selectTest = true
      }
Severity: Major
Found in frontend/src/Metamaps/JIT.js - About 40 mins to fix

Block has too many lines. [29/25]
Open

        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
          if is_plural

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [29/25]
Open

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  config.action_cable.allowed_request_origins = [
    'https://metamaps.herokuapp.com', 'http://metamaps.herokuapp.com', 'https://metamaps.cc'
Severity: Minor
Found in config/environments/production.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Function createSynapseWithParameters has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  createSynapseWithParameters: function(desc, category, permission,
    topic1, topic2) {
Severity: Minor
Found in frontend/src/Metamaps/Import.js - About 35 mins to fix

Function renderTopic has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  renderTopic: function(mapping, topic, createNewInDB, permitCreateSynapseAfter, opts = {}) {
Severity: Minor
Found in frontend/src/Metamaps/Topic.js - About 35 mins to fix

Function VideoView has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

var VideoView = function(video, $parent, id, isMyself, config) {
Severity: Minor
Found in frontend/src/Metamaps/Views/VideoView.js - About 35 mins to fix

Function renderSynapse has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  renderSynapse: function(mapping, synapse, node1, node2, createNewInDB) {
Severity: Minor
Found in frontend/src/Metamaps/Synapse.js - About 35 mins to fix

Function updateFilters has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  updateFilters: function(collection, propertyToCheck, correlatedModel, filtersToUse, listToModify) {
Severity: Minor
Found in frontend/src/Metamaps/Filter.js - About 35 mins to fix

Method notify_followers has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.notify_followers(entity, event_type, event, reason_filter = nil, exclude_follows = nil)
Severity: Minor
Found in app/services/notification_service.rb - About 35 mins to fix

Function resize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  resize: function() {
    const self = ReactApp
    const maps = ExploreMaps.collection
    const currentUser = Active.Mapper
    const user = maps && maps.id === 'mapper' ? ExploreMaps.mapper : null
Severity: Minor
Found in frontend/src/Metamaps/GlobalUI/ReactApp.js - 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

Function topicAdded has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  topicAdded: event => {
    const m = Active.Mapper
    // we receive a contentless model from the server
    // containing only the information we need to determine whether the active mapper
    // can view this topic, then if we determine it can, we make a call for the full model
Severity: Minor
Found in frontend/src/Metamaps/Cable.js - 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

Function createSynapseLocally has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  createSynapseLocally: function() {
    var self = Synapse
    let topic1
    let topic2
    let node1
Severity: Minor
Found in frontend/src/Metamaps/Synapse.js - 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

Function showCard has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  showCard: function(edge, e) {
    var self = SynapseCard

    // reset so we don't interfere with other edges, but first, save its x and y
    var myX = $('#edit_synapse').css('left')
Severity: Minor
Found in frontend/src/Metamaps/SynapseCard.js - 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

Function setAccessRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  setAccessRequest: function() {
    const self = Map
    if (Active.Mapper) {
      const request = _find(self.requests, r => r.user_id === Active.Mapper.id)
      if (!request) {
Severity: Minor
Found in frontend/src/Metamaps/Map/index.js - 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 init_metacodes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def init_metacodes
    %w[Action Aim Idea Question Note Wildcard Subject].map do |m|
      begin
        metacode = Metacode.find_by(name: m)
        metacode.id.to_s if metacode
Severity: Minor
Found in app/models/user_preference.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 pagination has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def pagination(collection)
        return @pagination_data unless @pagination_data.nil?

        current_page = (params[:page] || 1).to_i
        per = (params[:per] || 25).to_i
Severity: Minor
Found in app/controllers/api/v2/restful_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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @synapse = Synapse.new(synapse_params)
    @synapse.desc = '' if @synapse.desc.nil?
    @synapse.desc.strip! # no trailing/leading whitespace
    @synapse.user = current_user
Severity: Minor
Found in app/controllers/synapses_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

Avoid too many return statements within this method.
Open

        return user.settings.follow_map_on_contributed == '1' if reason == 'contributed'
Severity: Major
Found in app/services/follow_service.rb - About 30 mins to fix

Function removeEdge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  removeEdge: function(edge) {
    if (!Active.Map) return

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

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

Function render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const { conversationLive, mapperIsLive, isParticipating, isPending, id, self, image, username, color } = this.props
    return (
      <div className={`participant participant-${id} ${self ? 'is-self' : ''}`}>
        <div className="chat-participant-image">
Severity: Minor
Found in frontend/src/routes/MapView/MapChat/Participant.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

Severity
Category
Status
Source
Language