DemocracyOS/democracyos

View on GitHub

Showing 430 of 430 total issues

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

  signup.resendValidationEmail(req.body, meta, function (err) {
    if (err) return res.status(200).json({ error: err.message })
    return res.status(200).send()
  })
Severity: Major
Found in lib/api/signup/index.js and 2 other locations - About 1 hr to fix
lib/api/forgot/index.js on lines 46..49
lib/api/signup/index.js on lines 40..43

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

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

  bindShowEvents (bind = true) {
    super.bindShowEvents(bind)
    let action = bind ? 'on' : 'off'
    bean[action](this.input, 'blur', this.hide)
  }
lib/admin/admin-permissions/add-user-input/dropdown/dropdown.js on lines 273..277

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

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

  const topicUrl = utils.buildUrl(config, {
    pathname: urlBuilder.for('site.topic', {
      forum: req.forum.name,
      id: req.topic.id
    })
Severity: Major
Found in lib/api-v2/middlewares/notifications.js and 1 other location - About 1 hr to fix
lib/api-v2/middlewares/notifications.js on lines 59..64

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

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

  bindHideEvents (bind = true) {
    super.bindHideEvents(bind)
    let action = bind ? 'on' : 'off'
    bean[action](this.input, 'focus', this.show)
  }
lib/admin/admin-permissions/add-user-input/dropdown/dropdown.js on lines 267..271

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

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

  signup.doSignUp(profile, meta, function (err) {
    if (err) return res.status(400).json({ error: err.message })
    return res.status(200).send()
  })
Severity: Major
Found in lib/api/signup/index.js and 2 other locations - About 1 hr to fix
lib/api/forgot/index.js on lines 46..49
lib/api/signup/index.js on lines 72..75

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

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 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render () {
    const {
      name,
      title,
      description,
Severity: Minor
Found in lib/admin/admin-topics-form/attrs/component.js - About 1 hr to fix

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

    exports.up = function (done) {
      const clausesVersionsAcc = { 1: 0, 2: 0, 3: 0 }
    
      dbReady()
        .then(() => Topic.collection
    Severity: Minor
    Found in migrations/1487112733708-update-topic-clauses.js - About 1 hr to fix

      Function constructor has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        constructor (el, options = {}) {
          // The original input or textarea element
          let input = typeof el === 'string' ? dom(el) : el
      
          // Settings merged with options provided by callee
      Severity: Minor
      Found in lib/richtext/richtext.js - About 1 hr to fix

        Function validate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function validate (schemas, options) {
          var extensions = []
        
          options = options || {}
        
        
        Severity: Minor
        Found in lib/api-v2/validate/index.js - About 1 hr to fix

          Function postserialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            postserialize (data = {}) {
              if (data['links[][text]']) {
                data.links = data['links[][text]'].map((text, i) => ({
                  _id: data['links[][_id]'][i] || undefined,
                  url: data['links[][url]'][i],
          Severity: Minor
          Found in lib/admin/admin-topics-form/view.js - About 1 hr to fix

            Function sslRedirect has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function sslRedirect (app, options) {
              var secure = options.protocol === 'https'
            
              if (!secure) return
            
            
            Severity: Minor
            Found in lib/server-factory/ssl-redirect.js - About 1 hr to fix

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

                    data.push({
                      value: votes.neutral.length,
                      color: this.props.neutralColor,
                      label: t('proposal-options.abstain'),
                      labelColor: 'white',
              Severity: Major
              Found in lib/site/topic-layout/topic-article/vote/component.js and 2 other locations - About 1 hr to fix
              lib/site/topic-layout/topic-article/vote/component.js on lines 120..126
              lib/site/topic-layout/topic-article/vote/component.js on lines 134..140

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

              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

                    if (config.multiForum) {
                      menuItemAdmin = (
                        <li>
                          <Link to={urlBuilder.for('settings.forums')}>
                            {t('header.forums')}
              Severity: Major
              Found in lib/header/user-badge/component.js and 1 other location - About 1 hr to fix
              lib/header/user-badge/component.js on lines 58..66

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

              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.findOne(id)
                      .then(this.handleTopicUpdate)
                      .catch((err) => {
                        if (err.status === 404) return browserHistory.push('/404')
                        if (err.status === 401) return browserHistory.push('/401')
              Severity: Major
              Found in lib/site/connectors/topic.js and 1 other location - About 1 hr to fix
              lib/site/home-forum/component.js on lines 40..60

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

              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

                    } else {
                      menuItemAdmin = (
                        <li>
                          <Link to={urlBuilder.for('admin')}>
                            {t('header.admin')}
              Severity: Major
              Found in lib/header/user-badge/component.js and 1 other location - About 1 hr to fix
              lib/header/user-badge/component.js on lines 50..58

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

              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

                    data.push({
                      value: votes.positive.length,
                      color: this.props.positiveColor,
                      label: t('proposal-options.yea'),
                      labelColor: 'white',
              Severity: Major
              Found in lib/site/topic-layout/topic-article/vote/component.js and 2 other locations - About 1 hr to fix
              lib/site/topic-layout/topic-article/vote/component.js on lines 127..133
              lib/site/topic-layout/topic-article/vote/component.js on lines 134..140

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

              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

                  forumStore.findOneByName(name)
                    .then((forum) => {
                      query.forum = forum.id
                      if (u.has('tag')) query.tag = u.get('tag')
                      return Promise.all([
              Severity: Major
              Found in lib/site/home-forum/component.js and 1 other location - About 1 hr to fix
              lib/site/connectors/topic.js on lines 52..58

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

              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

                    data.push({
                      value: votes.negative.length,
                      color: this.props.negativeColor,
                      label: t('proposal-options.nay'),
                      labelColor: 'white',
              Severity: Major
              Found in lib/site/topic-layout/topic-article/vote/component.js and 2 other locations - About 1 hr to fix
              lib/site/topic-layout/topic-article/vote/component.js on lines 120..126
              lib/site/topic-layout/topic-article/vote/component.js on lines 127..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 57.

              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 up has a Cognitive Complexity of 10 (exceeds 5 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: Minor
              Found in migrations/1501737026342-update-topic-box.js - About 1 hr 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 parseUpdateableKeys has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              exports.parseUpdateableKeys = function parseUpdateableKeys (req, res, next) {
                const custom = (req.forum.topicsAttrs || []).map((attr) => {
                  return `attrs.${attr.name}`
                })
              
              
              Severity: Minor
              Found in lib/api-v2/middlewares/topics.js - About 1 hr 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