DemocracyOS/democracyos

View on GitHub

Showing 430 of 430 total issues

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

function _handleError (err, req, res) {
  log('Error found: %s', err)
  var error = err
  if (err.errors && err.errors.text) error = err.errors.text
  if (error.type) error = error.type
Severity: Major
Found in lib/api/topic/index.js and 1 other location - About 3 hrs to fix
lib/api/whitelist/index.js on lines 14..21

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

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

function _handleError (err, req, res) {
  log('Error found: %s', err)
  var error = err
  if (err.errors && err.errors.text) error = err.errors.text
  if (error.type) error = error.type
Severity: Major
Found in lib/api/whitelist/index.js and 1 other location - About 3 hrs to fix
lib/api/topic/index.js on lines 172..179

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

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

function VoteBox ({ onVote }) {
  return (
    <div className='vote-box'>
      <div className='vote-options'>
        <div className='direct-vote'>
Severity: Major
Found in lib/site/topic-layout/topic-article/hierarchy/component.js and 1 other location - About 3 hrs to fix
lib/site/topic-layout/topic-article/slider/component.js on lines 167..181

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

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

function VoteBox ({ onVote }) {
  return (
    <div className='vote-box'>
      <div className='vote-options'>
        <div className='direct-vote'>
Severity: Major
Found in lib/site/topic-layout/topic-article/slider/component.js and 1 other location - About 3 hrs to fix
lib/site/topic-layout/topic-article/hierarchy/component.js on lines 173..187

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

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

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

      exports.search = function search (query, fn) {
        log('Searching for topics matching %j', query)
      
        Topic
          .find(query, function (err, topics) {
      Severity: Major
      Found in lib/db-api/topic.js and 1 other location - About 3 hrs to fix
      lib/db-api/whitelist.js on lines 76..91

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

      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

      exports.search = function search (query, fn) {
        log('Searching for whitelists matching %j', query)
      
        Whitelist
          .find(query, function (err, whitelists) {
      Severity: Major
      Found in lib/db-api/whitelist.js and 1 other location - About 3 hrs to fix
      lib/db-api/topic.js on lines 54..69

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

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

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

                      topicStore.findAll(query).then(([topics, pagination]) => {
                        ctx.topics = topics
                        ctx.pagination = pagination
                        next()
                      }).catch((err) => {
                    Severity: Major
                    Found in lib/middlewares/topic-middlewares/topic-middlewares.js and 1 other location - About 2 hrs to fix
                    lib/middlewares/topic-middlewares/topic-middlewares.js on lines 34..41

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

                    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

                    exports.get = function get (id, fn) {
                      log('Looking for tag %j', id)
                      Tag.findById(id, function (err, tag) {
                        if (err) {
                          log('Found error %j', err)
                    Severity: Major
                    Found in lib/db-api/tag.js and 1 other location - About 2 hrs to fix
                    lib/db-api/token.js on lines 19..31

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

                    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

                      topicStore.findAll(query).then(([topics, pagination]) => {
                        ctx.topics = topics
                        ctx.pagination = pagination
                        next()
                      }).catch((err) => {
                    Severity: Major
                    Found in lib/middlewares/topic-middlewares/topic-middlewares.js and 1 other location - About 2 hrs to fix
                    lib/middlewares/topic-middlewares/topic-middlewares.js on lines 54..61

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

                    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

                    exports.get = function get (id, fn) {
                      log('Looking for token %j', id)
                      Token.findById(id, function (err, token) {
                        if (err) {
                          log('Found error %j', err)
                    Severity: Major
                    Found in lib/db-api/token.js and 1 other location - About 2 hrs to fix
                    lib/db-api/tag.js on lines 141..154

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

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

                      api.forums.find({ name: name })
                        .findOne()
                        .exec()
                        .then((forum) => {
                          if (!forum) return next(new Error404(name))
                    Severity: Major
                    Found in lib/api-v2/middlewares/forums.js and 2 other locations - About 2 hrs to fix
                    lib/api-v2/middlewares/comments.js on lines 6..16
                    lib/api-v2/middlewares/forums.js on lines 24..34

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

                    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