DemocracyOS/democracyos

View on GitHub

Showing 430 of 430 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  'min-length': (val, n, fn) => {
    var options = { n: n }
    var msg = n > 1 ? t('validators.min-length.plural', options) : t('validators.min-length.singular', options)
    msg = val.length < n ? msg : null
    fn(msg)
Severity: Major
Found in lib/validators/validators.js and 1 other location - About 2 hrs to fix
lib/validators/validators.js on lines 67..72

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 81.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                          !this.props.isOwner &&
                          !~this.props.flags.map((flag) => flag.author).indexOf(this.props.user.id) &&
                          (
                            <button onClick={this.props.onFlag}>
                              {t('comment-card.report-spam')}
    lib/site/topic-layout/topic-article/comments/list/comment/header/component.js on lines 64..71

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 80.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                          !this.props.isOwner &&
                          !!~this.props.flags.map((flag) => flag.author).indexOf(this.props.user.id) &&
                          (
                            <button onClick={this.props.onUnflag}>
                              {t('comment-card.not-spam')}
    lib/site/topic-layout/topic-article/comments/list/comment/header/component.js on lines 74..81

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 80.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

              var meta = {
                ip: req.ip,
                ips: req.ips,
                host: req.get('host'),
                origin: req.get('origin'),
            Severity: Major
            Found in lib/api/signup/index.js and 2 other locations - About 2 hrs to fix
            lib/api/forgot/index.js on lines 20..27
            lib/api/signup/index.js on lines 28..35

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 78.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

              var meta = {
                ip: req.ip,
                ips: req.ips,
                host: req.get('host'),
                origin: req.get('origin'),
            Severity: Major
            Found in lib/api/forgot/index.js and 2 other locations - About 2 hrs to fix
            lib/api/signup/index.js on lines 28..35
            lib/api/signup/index.js on lines 63..70

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 78.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

              var meta = {
                ip: req.ip,
                ips: req.ips,
                host: req.get('host'),
                origin: req.get('origin'),
            Severity: Major
            Found in lib/api/signup/index.js and 2 other locations - About 2 hrs to fix
            lib/api/forgot/index.js on lines 20..27
            lib/api/signup/index.js on lines 63..70

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 78.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        <ReplyContent
                          textHtml={reply.textHtml}
                          isOwner={isOwner}
                          editing={this.state.editing}
                          text={reply.text}
                lib/site/topic-layout/topic-article/comments/list/comment/component.js on lines 168..174

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 77.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        <CommentContent
                          textHtml={comment.textHtml}
                          isOwner={isOwner}
                          editing={this.state.editing}
                          text={comment.text}
                lib/site/topic-layout/topic-article/comments/list/comment/replies/list/component.js on lines 83..89

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 77.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                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

                Function up has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.up = function up (done) {
                  // mediaTitle 225
                  // author 100
                  // authorUrl 250
                  // source 250
                Severity: Major
                Found in migrations/1487112733702-update-topic-maxlengths.js - About 2 hrs to fix

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

                  import React, { Component } from 'react'
                  import { Link } from 'react-router'
                  import t from 't-component'
                  import debug from 'debug'
                  import config from 'lib/config'
                  Severity: Minor
                  Found in lib/site/home-multiforum/component.js - About 2 hrs to fix

                    Function up has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exports.up = function up (done) {
                      dbReady()
                        .then(() => Topic.collection.find({}).toArray())
                        .then(mapPromises(function (topic) {
                          if (topic.action && Object.keys(topic.action).includes('box')) return Promise.resolve(0)
                    Severity: Major
                    Found in migrations/1501737026342-update-topic-box.js - About 2 hrs to fix

                      Function xssFilter has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports = function xssFilter (opts) {
                        var defaults = {
                          fontFace: false,
                          fontSize: true,
                          fontWidth: true,
                      Severity: Major
                      Found in lib/richtext/lib/xss-filter.js - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language