DemocracyOS/democracyos

View on GitHub

Showing 161 of 430 total issues

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

  render () {
    return (
      <div className='center-container'>
        {
          this.state.active === 'form' &&
Severity: Major
Found in lib/site/sign-up/component.js - About 6 hrs to fix

    File index.js has 372 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const Comment = require('lib/models').Comment
    const privileges = require('lib/privileges/forum')
    const scopes = require('./scopes')
    
    /**
    Severity: Minor
    Found in lib/api-v2/db-api/comments/index.js - About 4 hrs to fix

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

        render () {
          const {
            comment,
            user,
            forum,

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

          render () {
            return (
              <div className='center-container'>
                {
                  this.state.active === 'form' &&
        Severity: Major
        Found in lib/site/resend/component.js - About 4 hrs to fix

          Function render has 106 lines of code (exceeds 25 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: Major
          Found in lib/site/home-multiforum/component.js - About 4 hrs to fix

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

            exports.up = function up (done) {
              // mediaTitle 225
              // author 100
              // authorUrl 250
              // source 250
            Severity: Minor
            Found in migrations/1487112733702-update-topic-maxlengths.js - About 4 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 index.js has 332 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const ObjectID = require('mongoose').Types.ObjectId
            const Topic = require('lib/models').Topic
            const Vote = require('lib/models').Vote
            const Comments = require('../comments')
            const scopes = require('./scopes')
            Severity: Minor
            Found in lib/api-v2/db-api/topics/index.js - About 4 hrs to fix

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

                render () {
                  const {
                    topic,
                    forum,
                    user
              Severity: Major
              Found in lib/site/topic-layout/topic-article/component.js - About 3 hrs to fix

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

                  render () {
                    const form = (
                      <FormAsync
                        action='/api/signin'
                        onSubmit={this.handleSubmit}
                Severity: Major
                Found in lib/site/sign-in/component.js - About 3 hrs to fix

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

                    render () {
                      const {
                        tags,
                        sort,
                        selectedTags,
                  Severity: Major
                  Found in lib/admin/admin-tags-moderation/component.js - About 3 hrs to fix

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

                      render () {
                        return (
                          <div className='article-container'>
                            <div className='article-content markdown-cheatsheet'>
                              <h3>{t('democracyos.markdown.flavored')}</h3>
                    Severity: Major
                    Found in lib/site/help/md-guide/component.js - About 3 hrs to fix

                      Function commentsSyncFactory has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function commentsSyncFactory () {
                        let items = []
                      
                        const params = {
                          topicId: null,
                      Severity: Major
                      Found in lib/site/topic-layout/topic-article/comments/connector.js - About 3 hrs to fix

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

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

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

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

                            Function parseUpdateableKeys has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            exports.parseUpdateableKeys = function parseUpdateableKeys (req, res, next) {
                              const custom = (req.forum.topicsAttrs || []).map((attr) => {
                                return `attrs.${attr.name}`
                              })
                            
                            
                            Severity: Major
                            Found in lib/api-v2/middlewares/topics.js - About 3 hrs to fix

                              File index.js has 292 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              const express = require('express')
                              const validate = require('../validate')
                              const middlewares = require('../middlewares')
                              const api = require('../db-api')
                              
                              
                              Severity: Minor
                              Found in lib/api-v2/comments/index.js - About 3 hrs to fix

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

                                  render () {
                                    const { title, name, summary, coverUrl, updated } = this.state
                                
                                    return (
                                      <article className='forum-edit-form col-xs-12 col-md-8 col-md-offset-2'>
                                Severity: Major
                                Found in lib/admin/admin-edit-forum/component.js - About 2 hrs to fix

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

                                  import React, { Component } from 'react'
                                  import Chart from 'chart.js'
                                  import t from 't-component'
                                  import topicStore from 'lib/stores/topic-store/topic-store'
                                  import userConnector from 'lib/site/connectors/user'
                                  Severity: Minor
                                  Found in lib/site/topic-layout/topic-article/vote/component.js - About 2 hrs to fix

                                    Function getTags has 72 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    exports.getTags = function getTags (opts) {
                                      const forum = new ObjectID(opts.forum._id)
                                      let sort = { 'count': -1 }
                                      if (opts.sort) {
                                        switch (opts.sort) {
                                    Severity: Major
                                    Found in lib/api-v2/db-api/topics/index.js - About 2 hrs to fix

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

                                      exports.resetPassword = function resetPassowrd (formData, callback) {
                                        log('password reset requested. token : [%s]', formData.token)
                                        exports.verifyToken(formData.token, function (err, token) {
                                          if (err) return callback(err)
                                          log('password reset requested. token : [%s]. token verified', formData.token)
                                      Severity: Minor
                                      Found in lib/api/forgot/lib/forgotpassword.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