DemocracyOS/democracyos

View on GitHub

Showing 161 of 430 total issues

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

          exports.commentReply = function commentReply (req, res, next) {
            api.user.get(req.comment.author.id, function (err, commentAuthor) {
              if (err) return next(err)
          
              const topic = {
          Severity: Minor
          Found in lib/api-v2/middlewares/notifications.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

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

                  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

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

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

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language