DemocracyOS/democracyos

View on GitHub

Showing 430 of 430 total issues

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

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

            user.save(function (err) {
              if (err) return callback(err)
              log('Saved user [%s]', user.id)
              token.remove(function (err) {
                if (err) return callback(err)
    Severity: Major
    Found in lib/api/forgot/lib/forgotpassword.js and 1 other location - About 2 hrs to fix
    lib/api/signup/lib/signup.js on lines 125..133

    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 84.

    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 2 locations. Consider refactoring.
    Open

          user.save(function (err) {
            if (err) return callback(err)
            log('Saved user [%s]', user.id)
            token.remove(function (err) {
              if (err) return callback(err)
    Severity: Major
    Found in lib/api/signup/lib/signup.js and 1 other location - About 2 hrs to fix
    lib/api/forgot/lib/forgotpassword.js on lines 102..110

    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 84.

    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 2 locations. Consider refactoring.
    Open

      api.tag.update(req.params.id, req.body, function (err, tagDoc) {
        if (err) return _handleError(err, req, res)
    
        log('Serving tag %s', tagDoc.id)
        var keys = [
    Severity: Major
    Found in lib/api/tag/index.js and 1 other location - About 2 hrs to fix
    lib/api/tag/index.js on lines 44..53

    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 84.

    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 2 locations. Consider refactoring.
    Open

      api.tag.get(req.params.id, function (err, tagDoc) {
        if (err) return _handleError(err, req, res)
    
        log('Serving tag %s', tagDoc.id)
        var keys = [
    Severity: Major
    Found in lib/api/tag/index.js and 1 other location - About 2 hrs to fix
    lib/api/tag/index.js on lines 71..80

    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 84.

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

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

        api.topics.find({ _id: id })
          .findOne()
          .exec()
          .then((topic) => {
            if (!topic) {
      Severity: Major
      Found in lib/api-v2/middlewares/topics.js and 1 other location - About 2 hrs to fix
      lib/api-v2/middlewares/topics.js on lines 60..73

      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 83.

      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

        var flagged = flags.filter(function (v) {
          var a = v.author.get ? v.author.get('_id') : v.author
          return a.equals
            ? a.equals(c)
            : a === c
      Severity: Major
      Found in lib/models/comment.js and 1 other location - About 2 hrs to fix
      lib/models/comment.js on lines 173..176

      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 83.

      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 4 locations. Consider refactoring.
      Open

            <div className='alert alert-info alert-voted' role='alert'>
              <span className='icon-info bold' />
              <span className='black bold thanks'>{t('topics.actions.thanks')}</span>
              <span className='black'>{t('topics.actions.feedback')}</span>
            </div>
      Severity: Major
      Found in lib/site/topic-layout/topic-article/hierarchy/component.js and 3 other locations - About 2 hrs to fix
      lib/site/topic-layout/topic-article/cause/component.js on lines 54..58
      lib/site/topic-layout/topic-article/slider/component.js on lines 202..206
      lib/site/topic-layout/topic-article/vote/component.js on lines 317..321

      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 83.

      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 4 locations. Consider refactoring.
      Open

            <div className='alert alert-info alert-voted' role='alert'>
              <span className='icon-info bold' />
              <span className='black bold thanks'>{t('topics.actions.thanks')}</span>
              <span className='black'>{t('topics.actions.feedback')}</span>
            </div>
      Severity: Major
      Found in lib/site/topic-layout/topic-article/vote/component.js and 3 other locations - About 2 hrs to fix
      lib/site/topic-layout/topic-article/cause/component.js on lines 54..58
      lib/site/topic-layout/topic-article/hierarchy/component.js on lines 154..158
      lib/site/topic-layout/topic-article/slider/component.js on lines 202..206

      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 83.

      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 4 locations. Consider refactoring.
      Open

            <div className='alert alert-info alert-voted' role='alert'>
              <span className='icon-info bold' />
              <span className='black bold thanks'>{t('topics.actions.thanks')}</span>
              <span className='black'>{t('topics.actions.feedback')}</span>
            </div>
      Severity: Major
      Found in lib/site/topic-layout/topic-article/slider/component.js and 3 other locations - About 2 hrs to fix
      lib/site/topic-layout/topic-article/cause/component.js on lines 54..58
      lib/site/topic-layout/topic-article/hierarchy/component.js on lines 154..158
      lib/site/topic-layout/topic-article/vote/component.js on lines 317..321

      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 83.

      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

        api.topics.find({ forum: id })
          .exec()
          .then((topics) => {
            if (!topics) {
              const err = new Error(`Topics from Forum ${id} not found.`)
      Severity: Major
      Found in lib/api-v2/middlewares/topics.js and 1 other location - About 2 hrs to fix
      lib/api-v2/middlewares/topics.js on lines 23..37

      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 83.

      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

        var voted = votes.filter(function (v) {
          var a = v.author.get ? v.author.get('_id') : v.author
          return a.equals ? a.equals(c) : a === c
        })
      Severity: Major
      Found in lib/models/comment.js and 1 other location - About 2 hrs to fix
      lib/models/comment.js on lines 220..225

      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 83.

      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 4 locations. Consider refactoring.
      Open

                  <div className='alert alert-info alert-voted' role='alert'>
                    <span className='icon-info bold' />
                    <span className='black bold thanks'>{t('topics.actions.thanks')}</span>
                    <span className='black'>{t('topics.actions.feedback')}</span>
                  </div>
      Severity: Major
      Found in lib/site/topic-layout/topic-article/cause/component.js and 3 other locations - About 2 hrs to fix
      lib/site/topic-layout/topic-article/hierarchy/component.js on lines 154..158
      lib/site/topic-layout/topic-article/slider/component.js on lines 202..206
      lib/site/topic-layout/topic-article/vote/component.js on lines 317..321

      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 83.

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

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

              request
                .put(this.url(id))
                .send({ data })
                .end((err, res) => {
                  if (err || !res.ok) return reject(err)
        Severity: Major
        Found in lib/stores/store/store.js and 1 other location - About 2 hrs to fix
        lib/stores/topic-store/topic-store.js on lines 100..110

        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 82.

        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

              request
                .post(`/api/v2/topics/${id}/vote`)
                .send({ value: value })
                .end((err, res) => {
                  if (err || !res.ok) return reject(err)
        Severity: Major
        Found in lib/stores/topic-store/topic-store.js and 1 other location - About 2 hrs to fix
        lib/stores/store/store.js on lines 195..205

        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 82.

        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

        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

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

              'max-length': (val, n, fn) => {
                var options = { n: n }
                var msg = n > 1 ? t('validators.max-length.plural', options) : t('validators.max-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 60..65

            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

            Severity
            Category
            Status
            Source
            Language