DemocracyOS/democracyos

View on GitHub

Showing 161 of 430 total issues

Function up has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

exports.up = function up (done) {
  // firstName 100
  // lastName 100
  // username 100
  // email 200
Severity: Minor
Found in migrations/1487112733700-update-users-maxlengths.js - About 2 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

File view.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import React from 'react'
import { render as ReactRender } from 'react-dom'
import closest from 'component-closest'
import confirm from 'democracyos-confirmation'
import Datepicker from 'democracyos-datepicker'
Severity: Minor
Found in lib/admin/admin-topics-form/view.js - About 2 hrs to fix

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

      render () {
        var learnMore = null
        if (config.learnMoreUrl) {
          learnMore = (
            <div className='alert alert-warning alert-dismissable system-alert'>
    Severity: Major
    Found in lib/site/topic-layout/topic-article/header/component.js - About 2 hrs to fix

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

        render () {
          return (
            <div className='center-container'>
              <div className='notifications-page'>
                <h1>{t('notifications.title')}</h1>
      Severity: Major
      Found in lib/site/notifications/component.js - About 2 hrs to fix

        FormView has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export default class FormView extends View {
          constructor (template, options = {}) {
            super(template, options)
            this.autovalidate('form[autovalidate]')
            this.autosubmit('form[autosubmit]')
        Severity: Minor
        Found in lib/form-view/form-view.js - About 2 hrs to fix

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

            render () {
              const { user, topic } = this.props
          
              const votes = this.state.votes
              const votesTotal = topic.action.count
          Severity: Major
          Found in lib/site/topic-layout/topic-article/vote/component.js - About 2 hrs to fix

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

              render () {
                const currentSort = this.props.sorts[this.props.currentSort]
            
                return (
                  <div className='sidebar-filter'>
            Severity: Major
            Found in lib/site/topic-layout/sidebar/filter/component.js - About 2 hrs to fix

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

                render () {
                  const { value, changingVote, colored } = this.state
                  const { topic, user } = this.props
              
                  const votesTotal = topic.action.count
              Severity: Major
              Found in lib/site/topic-layout/topic-article/slider/component.js - About 2 hrs to fix

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

                  render () {
                    const styles = {
                      color: config.headerFontColor,
                      backgroundColor: config.headerBackgroundColor
                    }
                Severity: Major
                Found in lib/header/component.js - About 2 hrs to fix

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

                    render () {
                      const { value, changingVote, items } = this.state
                      const { topic, user } = this.props
                  
                      const votesTotal = topic.action.count
                  Severity: Major
                  Found in lib/site/topic-layout/topic-article/hierarchy/component.js - About 2 hrs to fix

                    File component.js has 264 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import React, { Component } from 'react'
                    import InputRange from 'react-input-range'
                    import { VictoryChart, VictoryBar, Bar, VictoryAxis, VictoryTooltip } from 'victory'
                    import t from 't-component'
                    import userConnector from 'lib/site/connectors/user'
                    Severity: Minor
                    Found in lib/site/topic-layout/topic-article/slider/component.js - About 2 hrs to fix

                      Dropdown has 22 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      export class Dropdown {
                        constructor (options = {}) {
                          if (!options.container) {
                            throw new Error('Dropdown needs a container element.')
                          }
                      Severity: Minor
                      Found in lib/admin/admin-permissions/add-user-input/dropdown/dropdown.js - About 2 hrs to fix

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

                          render () {
                            const { reply } = this.props
                            return (
                              <header className={`meta ${(reply.author.badge ? ' has-badge' : '')}`}>
                                <img

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

                            render () {
                              return (
                                <div className='center-container'>
                                  <div id='forgot-form'>
                                    <div className='title-page'>
                          Severity: Major
                          Found in lib/site/forgot/component.js - About 2 hrs to fix

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

                              render () {
                                const userAttrs = this.props.user.state.value
                                let menuItemAdmin = null
                            
                                if (userAttrs.privileges && userAttrs.privileges.canManage) {
                            Severity: Major
                            Found in lib/header/user-badge/component.js - About 2 hrs to fix

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

                                render () {
                                  if (this.props.user.state.pending) return null
                              
                                  const { user, topic } = this.props
                                  const { results, changingVote, selected } = this.state
                              Severity: Major
                              Found in lib/site/topic-layout/topic-article/poll/component.js - About 2 hrs to fix

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

                                  render () {
                                    const { commentsFetch } = this.props
                                
                                    return (
                                      <div className='topic-comments'>
                                Severity: Major
                                Found in lib/site/topic-layout/topic-article/comments/component.js - About 2 hrs to fix

                                  Function authMongoose has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = function authMongoose (schema, options) {
                                    const digestAlgorithm = 'sha512'
                                  
                                    schema.plugin(passportLocalMongoose, {
                                      usernameField: 'email',
                                  Severity: Major
                                  Found in lib/auth/mongoose.js - About 2 hrs to fix

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

                                      render () {
                                        const {
                                          topic,
                                          user
                                        } = this.props

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

                                        render () {
                                          if (this.state.loadingUserForms) return null
                                          if (this.props.user.state.pending) return null
                                      
                                          const user = this.props.user.state.value || {}
                                      Severity: Minor
                                      Found in lib/site/home-multiforum/component.js - About 2 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