DemocracyOS/democracyos

View on GitHub

Showing 430 of 430 total issues

Function componentWillMount has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  componentWillMount () {
    if (!config.multiForum && !config.defaultForum) {
      window.location = urlBuilder.for('forums.new')
    }

Severity: Minor
Found in lib/site/home-forum/component.js - About 1 hr to fix

    Function doVote has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function doVote (user, value, topic) {
      if (topic.status === 'closed') {
        const err = new Error('Voting on this topic os closed.')
        err.code = 'VOTING_CLOSED'
        return Promise.reject(err)
    Severity: Minor
    Found in lib/api-v2/db-api/topics/index.js - About 1 hr to fix

      Function CommentsList has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function CommentsList (props) {
        const comments = props.comments || []
      
        return (
          <div
      Severity: Minor
      Found in lib/site/topic-layout/topic-article/comments/list/component.js - About 1 hr to fix

        Function create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.create = function create (data, fn) {
          log('Creating new whitelist %j', data)
        
          if (data.type === 'email') {
            var batch = new Batch()
        Severity: Minor
        Found in lib/db-api/whitelist.js - About 1 hr to fix

          Function create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          exports.create = function create (tag, fn) {
            log('Creating new tag %j', tag)
          
            if (typeof tag === 'string') {
              tag = { name: tag }
          Severity: Minor
          Found in lib/db-api/tag.js - About 1 hr to fix

            Function canEdit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              canEdit (forum, user, topic) {
                if (!config.multiForum && user && user.staff) return true
            
                const isAdmin =
                  forum.isOwner(user) ||
            Severity: Minor
            Found in lib/privileges/topic.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

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

            CommentSchema.virtual('downvotes').get(function () {
              return this.votes.filter(function (v) {
                return v.value === 'negative'
              })
            })
            Severity: Major
            Found in lib/models/comment.js and 1 other location - About 1 hr to fix
            lib/models/comment.js on lines 102..106

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

            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

            CommentSchema.virtual('upvotes').get(function () {
              return this.votes.filter(function (v) {
                return v.value === 'positive'
              })
            })
            Severity: Major
            Found in lib/models/comment.js and 1 other location - About 1 hr to fix
            lib/models/comment.js on lines 115..119

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

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

              prepareState (topic) {
                let votes = {
                  positive: new Array(parseInt(topic.action.results.find((o) => o.value === 'positive').percentage * topic.action.count)) || [],
                  negative: new Array(parseInt(topic.action.results.find((o) => o.value === 'negative').percentage * topic.action.count)) || [],
                  neutral: new Array(parseInt(topic.action.results.find((o) => o.value === 'neutral').percentage * topic.action.count)) || []
            Severity: Minor
            Found in lib/site/topic-layout/topic-article/vote/component.js - About 1 hr to fix

              Function CommentContent has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function CommentContent (props) {
                let Content = (
                  <div
                    className='text'
                    dangerouslySetInnerHTML={{ __html: props.textHtml }} />

                Function ReplyContent has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function ReplyContent (props) {
                  let Content = (
                    <div
                      className='text'
                      dangerouslySetInnerHTML={{ __html: props.textHtml }} />

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

                    numeric: (val, option, fn) => {
                      fn(!regexps.numeric.test(val) && val.trim() !== '' ? t('validators.invalid.number') : null)
                    },
                  Severity: Major
                  Found in lib/validators/validators.js and 1 other location - About 1 hr to fix
                  lib/validators/validators.js on lines 56..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 59.

                  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

                      .then((users) => User.collection.deleteMany({ email: { $in: config.blackListEmails.map((d) => new RegExp(`@${d}*$`)) } })
                        .then(() => Vote.collection.deleteMany({ author: { $in: users.map((u) => u._id) } })))
                  Severity: Major
                  Found in migrations/1503424667703-add-blacklist-email.js and 1 other location - About 1 hr to fix
                  migrations/1503424667703-add-blacklist-email.js on lines 18..18

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

                  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

                      .then(() => User.collection.find({ email: { $in: config.blackListEmails.map((d) => new RegExp(`@${d}*$`)) } }).toArray())
                  Severity: Major
                  Found in migrations/1503424667703-add-blacklist-email.js and 1 other location - About 1 hr to fix
                  migrations/1503424667703-add-blacklist-email.js on lines 19..20

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

                  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

                    password: (val, option, fn) => {
                      fn(!regexps.password.test(val) && val.trim() !== '' ? t('invalid.password') : null)
                    },
                  Severity: Major
                  Found in lib/validators/validators.js and 1 other location - About 1 hr to fix
                  lib/validators/validators.js on lines 52..54

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

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

                  module.exports = function topicsAttrs (ForumSchema) {
                    const AttrSchema = new Schema({
                      name: { type: String, maxlength: 32, minlength: 1, required: true },
                      title: { type: String, maxlength: 128, minlength: 1, required: true },
                      description: { type: String, maxlength: 256 },
                  Severity: Minor
                  Found in lib/models/forum/topics-attrs.js - About 1 hr to fix

                    Function createToken has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    exports.createToken = function createToken (email, meta, callback) {
                      log('Password reset token creation requested for email "%s", checking user exists', email)
                    
                      if (arguments.length === 2) {
                        callback = meta
                    Severity: Minor
                    Found in lib/api/forgot/lib/forgotpassword.js - About 1 hr to fix

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

                        render () {
                          return (
                            <div className='header-item'>
                              {
                                this.state.signup &&
                      Severity: Minor
                      Found in lib/header/anon-user/component.js - About 1 hr to fix

                        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 21..26

                        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

                          forgotpassword.verifyToken(req.body.token, function (err) {
                            if (err) return res.status(500).json({ error: err.message })
                            return res.status(200).send()
                          })
                        Severity: Major
                        Found in lib/api/forgot/index.js and 2 other locations - About 1 hr to fix
                        lib/api/signup/index.js on lines 40..43
                        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

                        Severity
                        Category
                        Status
                        Source
                        Language