DemocracyOS/app

View on GitHub

Showing 161 of 430 total issues

Function mixin has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function mixin (Base, ...theMixins) {
  let constructors = []

  if (typeof Base !== 'function') {
    theMixins.unshift(Base)
Severity: Minor
Found in lib/utils/mixin.js - About 1 hr to fix

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

      render () {
        const voted = this.props.user.state.fulfilled && this.props.item.voted
    
        return (
          <li className='sidebar-link' data-id={this.props.item.id}>
    Severity: Minor
    Found in lib/site/topic-layout/sidebar/list/list-item/component.js - About 1 hr to fix

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

        render () {
          let renderState
      
          if (!this.props.isLoading && !this.props.noMoreResults) {
            renderState = (
      Severity: Minor
      Found in lib/site/home-multiforum/search-results/load-more/index.js - About 1 hr to fix

        Function doSignUp has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        exports.doSignUp = function doSignUp (profile, meta, callback) {
          const strategySignup = () => {
            profile.email = normalizeEmail(profile.email)
            var user = new User(profile)
        
        
        Severity: Minor
        Found in lib/api/signup/lib/signup.js - About 1 hr to fix

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

          exports.up = function up (done) {
            dbReady()
              .then(() => config.blackListEmails ? Promise.resolve() : Promise.reject())
              .then(() => User.collection.find({ email: { $in: config.blackListEmails.map((d) => new RegExp(`@${d}*$`)) } }).toArray())
              .then((users) => User.collection.deleteMany({ email: { $in: config.blackListEmails.map((d) => new RegExp(`@${d}*$`)) } })
          Severity: Minor
          Found in migrations/1503424667703-add-blacklist-email.js - About 1 hr to fix

            Function getTopics has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getTopics (req, res, next) {
              Promise.all([
                api.topics.list({
                  user: req.user,
                  forum: req.forum,
            Severity: Minor
            Found in lib/api-v2/topics/index.js - About 1 hr to fix

              Function watch has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  watch: function () {
                    const log = newLog('js:watch')
              
                    const bs = Object.keys(entries).map(function (target) {
                      const opts = {
              Severity: Minor
              Found in lib/build/js.js - About 1 hr to fix

                Function removeComment has a Cognitive Complexity of 9 (exceeds 5 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 55 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 canCreateForum has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                exports.canCreateForum = function canCreateForum (req, res, next) {
                  if (config.multiForum) {
                    if (!config.restrictForumCreation) return next()
                    if (!req.user || !req.user.staff) {
                      log('Forums must be created by a staff members only.')
                Severity: Minor
                Found in lib/middlewares/forum-middlewares/index.js - About 55 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 render has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  render () {
                    var learnMore = null
                    if (config.learnMoreUrl) {
                      learnMore = (
                        <div className='alert alert-warning alert-dismissable system-alert'>
                Severity: Minor
                Found in lib/site/topic-layout/topic-article/header/component.js - About 55 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 cleanup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  cleanup () {
                    for (let i in this) {
                      if (i === '_eventCollection') continue
                      if (i.charAt(0) === '$') continue
                      if (!this.hasOwnProperty(i)) continue
                Severity: Minor
                Found in lib/user/model.js - About 55 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 deeply nested control flow statements.
                Open

                      if (!attrs[key] || attrs[key] === 'false' || attrs[key] === 'off') {
                        attrs[key] = undefined
                      } else {
                        attrs[key] = true
                      }
                Severity: Major
                Found in lib/api-v2/middlewares/topics.js - About 45 mins to fix

                  Function postserialize has a Cognitive Complexity of 8 (exceeds 5 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 45 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 getIdString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  exports.getIdString = function getIdString (id) {
                    if (!id) {
                      throw new Error('Invalid id value')
                    }
                  
                  
                  Severity: Minor
                  Found in lib/utils/index.js - About 45 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 guessVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function guessVersion (topic) {
                    const migratedClauses = topic.clauses.filter(function (clause) {
                      return !!clause.markup
                    })
                  
                  
                  Severity: Minor
                  Found in migrations/1487112733708-update-topic-clauses.js - About 45 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 lookup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function lookup (formats, types) {
                    for (var i = 0; i < formats.length; i++) {
                      const format = formats[i].replace('*', '')
                      if (!format) continue
                  
                  
                  Severity: Minor
                  Found in lib/accepts/index.js - About 45 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 field has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  export function field (name, options, val, ctx, print, fn) {
                  Severity: Minor
                  Found in lib/form-view/validate/validate.js - About 45 mins to fix

                    Function Setup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function Setup (app) {
                      /**
                       * Set `production` settings
                       */
                    
                    
                    Severity: Minor
                    Found in lib/setup/index.js - About 45 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

                    Consider simplifying this complex logical expression.
                    Open

                            if (
                              !mediaTitleInvalid &&
                              !authorInvalid &&
                              !authorUrlInvalid &&
                              !sourceInvalid &&
                    Severity: Major
                    Found in migrations/1487112733702-update-topic-maxlengths.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if (this.state.isSearching) {
                            section = (
                              <SearchResults isLoading={this.state.isLoadingLoadMoreSearch} noMoreResults={this.state.noMoreResults} forums={this.state.searchResults} handleLoadMoreSearch={this.handleLoadMoreSearch} />
                            )
                          } else {
                      Severity: Major
                      Found in lib/site/home-multiforum/component.js - About 40 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language