metamaps/metamaps

View on GitHub

Showing 183 of 2,044 total issues

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

  render() {
    if (this.props.authorizedToEdit) {
      return (
        <span className="title">
          <RIETextArea value={this.props.name}
Severity: Minor
Found in frontend/src/components/TopicCard/Title.js - About 1 hr to fix

Method update has 39 lines of code (exceeds 25 allowed). Consider refactoring.
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 - About 1 hr to fix

Function handleURL has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  handleURL: function(url, opts = {}) {
    let coords = opts.coords
    if (!coords || coords.x === undefined || coords.y === undefined) {
      coords = AutoLayout.getNextCoord({ mappings: DataModel.Mappings })
    }
Severity: Minor
Found in frontend/src/Metamaps/Import.js - About 1 hr to fix

Function add_perms_form has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  add_perms_form: function(synapse) {
    // permissions - if owner, also allow permission editing
    $('#editSynLowerBar').append('<div class="mapPerm ' + synapse.get('permission').substring(0, 2) + '"></div>')

    // ability to change permission
Severity: Minor
Found in frontend/src/Metamaps/SynapseCard.js - About 1 hr to fix

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

  render () {
    const { currentUser, signInPage, unreadNotificationsCount,
            notifications, fetchNotifications, openInviteLightbox,
            markAsRead, markAsUnread } = this.props
    const { accountBoxOpen, notificationsBoxOpen } = this.state
Severity: Minor
Found in frontend/src/components/UpperRightUI.js - About 1 hr to fix

Function getNextCoord has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  getNextCoord: function(opts = {}) {
    var self = AutoLayout
    var nextX = self.nextX
    var nextY = self.nextY

Severity: Minor
Found in frontend/src/Metamaps/AutoLayout.js - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
Open

        'render': function(node, canvas) {
          const pos = node.pos.getc(true)
          const dim = node.getData('dim')
          const topic = node.getData('topic')
          const metacode = topic ? topic.getMetacode() : false
Severity: Minor
Found in frontend/src/Metamaps/JIT.js - About 1 hr 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 should_auto_follow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def should_auto_follow(entity, user, reason)
      follow = Follow.where(followed: entity, user: user).first
      return false if follow && follow.muted
      if entity.class == Topic
        return user.settings.follow_topic_on_created == '1' if reason == 'created'
Severity: Minor
Found in app/services/follow_service.rb - About 1 hr 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 getNextCoord has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  getNextCoord: function(opts = {}) {
    var self = AutoLayout
    var nextX = self.nextX
    var nextY = self.nextY

Severity: Minor
Found in frontend/src/Metamaps/AutoLayout.js - About 1 hr to fix

Function canvasClickHandler has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  canvasClickHandler: function(canvasLoc, e) {
    // grab the location and timestamp of the click
    const storedTime = Mouse.lastCanvasClick
    const now = Date.now() // not compatible with IE8 FYI
    Mouse.lastCanvasClick = now
Severity: Minor
Found in frontend/src/Metamaps/JIT.js - About 1 hr to fix

Function createSynapseLocally has 35 lines of code (exceeds 25 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 1 hr to fix

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

  render () {
    const { children, toast, unreadNotificationsCount, openInviteLightbox,
            mobile, mobileTitle, mobileTitleWidth, mobileTitleClick, location,
            map, userRequested, requestAnswered, requestApproved, serverData,
            onRequestAccess, notifications, fetchNotifications,
Severity: Minor
Found in frontend/src/routes/App.js - About 1 hr to fix

Function add_desc_form has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  add_desc_form: function(synapse) {
    var dataNil = 'Click to add description.'

    // TODO make it so that this would work even in sandbox mode,
    // currently with Best_in_place it won't
Severity: Minor
Found in frontend/src/Metamaps/SynapseCard.js - About 1 hr to fix

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

  render () {
    const { currentUser, map, topic, canEditMap, filterBoxHtml, onFilterClick, onImportClick, onForkClick,
            filterData, allForFiltering, visibleForFiltering, toggleMetacode, toggleMapper, toggleSynapse,
            filterAllMetacodes, filterAllMappers, filterAllSynapses } = this.props
    const { filterBoxOpen } = this.state
Severity: Minor
Found in frontend/src/components/UpperOptions.js - About 1 hr to fix

Function showImagePreview has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  showImagePreview: function() {
    var file = $('#user_image')[0].files[0]

    var reader = new window.FileReader()

Severity: Minor
Found in frontend/src/Metamaps/Account.js - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

      if (fromNodeX >= minBoxX && fromNodeX <= maxBoxX && fromNodeY >= minBoxY && fromNodeY <= maxBoxY && toNodeX >= minBoxX && toNodeX <= maxBoxX && toNodeY >= minBoxY && toNodeY <= maxBoxY) {
        selectTest = true
      }
Severity: Critical
Found in frontend/src/Metamaps/JIT.js - About 1 hr to fix

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

  init: function(serverData) {
    var self = DataModel

    // workaround circular import problem
    if (!self.MapCollection.model) self.MapCollection.model = Map
Severity: Minor
Found in frontend/src/Metamaps/DataModel/index.js - About 1 hr to fix

Function fork has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  fork: function() {
    GlobalUI.openLightbox('forkmap')

    let nodesData = ''
    let synapsesData = ''
Severity: Minor
Found in frontend/src/Metamaps/Map/index.js - About 1 hr to fix

Function createTopicWithParameters has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  createTopicWithParameters: function(name, metacodeName, permission, desc,
    link, xloc, yloc, importId, opts = {}) {
    var self = Import
    $(document).trigger(Map.events.editedByActiveMapper)
    var metacode = DataModel.Metacodes.where({name: metacodeName})[0] || null
Severity: Minor
Found in frontend/src/Metamaps/Import.js - About 1 hr to fix

Function updateFromPath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  updateFromPath: function(path) {
    const self = ExploreMaps
    const [_unused, generalSection, specificSection, id] = path.split('/')

    if (generalSection === 'explore') {
Severity: Minor
Found in frontend/src/Metamaps/Views/ExploreMaps.js - About 1 hr 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