DemocracyOS/app

View on GitHub

Showing 161 of 430 total issues

Function getMaxValues has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function getMaxValues (optionsWithMaxVotes, level, index, fieldsToExclude = [], fieldsTofind = []) {
Severity: Minor
Found in lib/api-v2/db-api/topics/utils.js - About 35 mins to fix

    Function down has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.down = function down (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 35 mins 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 serial has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.serial = function serial () {
      var middlewares = Array.prototype.slice.call(arguments)
    
      return function serialExec (req, res, next) {
        ;(function iterate (m) {
    Severity: Minor
    Found in lib/middlewares/utils/index.js - About 35 mins 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 CommentFooter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function CommentFooter (props) {
      return (
        <footer className='actions'>
          <div className='votes'>
            <span className='score'>

    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 serial has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export function serial (...middlewares) {
      return function serialExec (ctx, next) {
        ;(function iterate (m) {
          if (!m.length) return next()
          m[0](ctx, function (err) {
    Severity: Minor
    Found in lib/middlewares/utils/utils.js - About 35 mins 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 apiError has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    app.use(function apiError (err, req, res, next) {
      const status = err.status || 500
    
      const error = {
        code: 'SERVER_ERROR',
    Severity: Minor
    Found in lib/api-v2/boot/index.js - About 35 mins 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 paragraphToHTML has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function paragraphToHTML (paragraph, options) {
      if (!paragraph) return ''
      var el = o(paragraph.markup)
      // Set the ID
      el.attr(DATA_ID_ATTR, paragraph.id)
    Severity: Minor
    Found in lib/admin/admin-topics-form/body-serializer.js - About 35 mins 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 authMongoose has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function authMongoose (schema, options) {
      const digestAlgorithm = 'sha512'
    
      schema.plugin(passportLocalMongoose, {
        usernameField: 'email',
    Severity: Minor
    Found in lib/auth/mongoose.js - About 35 mins 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 revokePermission has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.revokePermission = function revokePermission (forumId, user, role) {
      log(`Revoking permissions to ${user} on forum ${forumId}.`)
    
      return new Promise((resolve, reject) => {
        Forum.findById(forumId, (findError, forum) => {
    Severity: Minor
    Found in lib/db-api/forum.js - About 35 mins 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 unflag has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    CommentSchema.methods.unflag = function (user, cb) {
      var flags = this.flags
      var c = user.get ? user.get('_id') : user
    
      var flagged = flags.filter(function (v) {
    Severity: Minor
    Found in lib/models/comment.js - About 35 mins 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 unvote has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    CommentSchema.methods.unvote = function (user, cb) {
      var votes = this.votes
      var c = user.get ? user.get('_id') : user
    
      var voted = votes.filter(function (v) {
    Severity: Minor
    Found in lib/models/comment.js - About 35 mins 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 grantPermission has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.grantPermission = function grantPermission (forumId, user, role) {
      log('Granting permissions as role %s to user %s of forum with id %s', role, user, forumId)
      return new Promise((resolve, reject) => {
        Forum.findById(forumId, (findError, forum) => {
          if (findError) return reject(findError)
    Severity: Minor
    Found in lib/db-api/forum.js - About 35 mins 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 privilegesMiddlewareGenerator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.privileges = function privilegesMiddlewareGenerator (privilege) {
      if (!privileges[privilege]) throw new Error('Wrong topi privilege name.')
    
      return function privilegesMiddleware (req, res, next) {
        var forum = req.forum
    Severity: Minor
    Found in lib/middlewares/topic-middlewares/index.js - About 35 mins 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

    Avoid too many return statements within this function.
    Open

        return false
    Severity: Major
    Found in lib/privileges/topic.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return false
      Severity: Major
      Found in lib/privileges/topic.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return next()
        Severity: Major
        Found in lib/api/signin/index.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return 3
          Severity: Major
          Found in migrations/1487112733708-update-topic-clauses.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                if (forum.hasRole(user, 'author') && topic.draft) return true
            Severity: Major
            Found in lib/privileges/topic.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return 2
              Severity: Major
              Found in migrations/1487112733708-update-topic-clauses.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    if (isAdmin) return true
                Severity: Major
                Found in lib/privileges/topic.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language