DemocracyOS/app

View on GitHub

Showing 161 of 430 total issues

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

  render () {
    const { reply, user, forum } = this.props
    const userAttrs = user.state.value || {}
    const isOwner = userAttrs.id === reply.author.id

    Function removeComment has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.removeComment = (function () {
      function verifyPrivileges (forum, user, comment) {
        if (privileges.canDeleteComments(forum, user)) return comment
    
        if (!comment.author.equals(user._id)) {
    Severity: Minor
    Found in lib/api-v2/db-api/comments/index.js - About 1 hr to fix

      Function switchOn has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        switchOn () {
          this.bind('click', '.add-link', this.bound('onaddlinkclick'))
          this.bind('click', '.forum-tag', this.bound('onaddforumtagclick'))
          this.bind('click', '[data-remove-link]', this.bound('onremovelinkclick'))
          this.bind('click', '.save', this.bound('onsaveclick'))
      Severity: Minor
      Found in lib/admin/admin-topics-form/view.js - About 1 hr to fix

        Function exports has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function () {
          const callbackURL = utils.buildUrl(config, {
            pathname: '/auth/facebook/callback'
          })
        
        
        Severity: Minor
        Found in lib/site/auth-facebook/strategy.js - About 1 hr to fix

          Function buildJs has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function buildJs (entries) {
            return {
              build: function () {
                const log = newLog('js:build')
          
          
          Severity: Minor
          Found in lib/build/js.js - About 1 hr to fix

            Function parseComment has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function parseComment (comment) {
              return new Promise((resolve, reject) => {
                if (!comment.text) return resolve(comment)
                marked(comment.text, {
                  sanitize: true,
            Severity: Minor
            Found in lib/site/topic-layout/topic-article/comments/parse-comment.js - About 1 hr to fix

              Function confirm has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export default function confirm (options = {}) {
                if (typeof options === 'string') {
                  options = { text: options.toString() }
                }
              
              
              Severity: Minor
              Found in lib/modals/confirm.js - About 1 hr to fix

                Function all has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.all = function all (options, fn) {
                  if (typeof options === 'function') {
                    fn = options
                    options = undefined
                  }
                Severity: Minor
                Found in lib/db-api/forum.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 all has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.all = function all (options, fn) {
                  if (typeof options === 'function') {
                    fn = options
                    options = undefined
                  }
                Severity: Minor
                Found in lib/db-api/forum.js - About 1 hr to fix

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

                    constructor (topic, forum, tags) {
                      const locals = {
                        form: { title: null, action: null, method: null, type: null },
                        topic: topic || { clauses: [] },
                        tags: tags,
                  Severity: Minor
                  Found in lib/admin/admin-topics-form/view.js - About 1 hr to fix

                    Function getCsv has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function getCsv (req, res, next) {
                      api.comments.populateTopics(req.topics)
                        .then((topicsComments) => {
                          const commentsData = [ titles ]
                    
                    
                    Severity: Minor
                    Found in lib/api-v2/comments/csv.js - About 1 hr to fix

                      Function down has 37 lines of code (exceeds 25 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 1 hr to fix

                        Function removeReply has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        exports.removeReply = (function () {
                          function verifyPrivileges (forum, user, replyId, comment) {
                            if (privileges.canDeleteComments(forum, user)) return comment
                        
                            const reply = comment.replies.id(replyId)
                        Severity: Minor
                        Found in lib/api-v2/db-api/comments/index.js - About 1 hr to fix

                          Function xssFilter has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          module.exports = function xssFilter (opts) {
                            var defaults = {
                              fontFace: false,
                              fontSize: true,
                              fontWidth: true,
                          Severity: Minor
                          Found in lib/richtext/lib/xss-filter.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 signin has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function signin (req, res, next) {
                            var email = normalizeEmail(req.body.email)
                            auth(email, req.body.password, function (err, user, info) {
                              if (err) return res.status(200).json({ error: t(err.message) })
                          
                          
                          Severity: Minor
                          Found in lib/api/signin/index.js - About 1 hr to fix

                            Function onload has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                reader.onload = (event) => {
                                  const content = event.target.result
                                  fetch(`/api/v2/topics.csv?forum=${this.props.forum.id}`, {
                                    method: 'POST',
                                    credentials: 'same-origin',
                            Severity: Minor
                            Found in lib/admin/admin-topics/export-update/component.js - About 1 hr to fix

                              Function user has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                user: function user () {
                                  return function (req, res, next) {
                                    var qs = req.query ? req.query.access_token : ''
                                    var encoded = req.cookies.token || qs || req.headers['x-access-token']
                              
                              
                              Severity: Minor
                              Found in lib/jwt/index.js - About 1 hr to fix

                                Function up has 33 lines of code (exceeds 25 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/1503256241267-update-topic-votes.js - About 1 hr to fix

                                  Function listen has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = function listen (opts, callback) {
                                    if (!callback) callback = () => {}
                                  
                                    const servers = serverFactory(app, opts)
                                  
                                  
                                  Severity: Minor
                                  Found in lib/server/index.js - About 1 hr to fix

                                    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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language