zuzak/gov.zk

View on GitHub

Showing 14 of 32 total issues

File books.js has 400 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var app = require('..')
var isbn = require('node-isbn')
var shuffle = require('shuffle-array')
var fs = require('fs')
var irc = require('../irc.js')
Severity: Minor
Found in routes/books.js - About 5 hrs to fix

    Function getStats has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getStats = async (loggedIn) => {
      const playerCommand = loggedIn ? '/p' : '/p o'
      const getImage = new Promise((resolve, reject) => {
        const path = '/home/zuzak/public_html/zuzakistan.com/public/factorio/map/d-c277191a/zoom_5'
        randomFile(path, (err, file) => {
    Severity: Minor
    Found in routes/factorio.js - About 1 hr to fix

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

      const getStats = async (loggedIn) => {
        const playerCommand = loggedIn ? '/p' : '/p o'
        const getImage = new Promise((resolve, reject) => {
          const path = '/home/zuzak/public_html/zuzakistan.com/public/factorio/map/d-c277191a/zoom_5'
          randomFile(path, (err, file) => {
      Severity: Minor
      Found in routes/factorio.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 __ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      global.__ = function (phrase, args) {
        if (getLocale() === 'qqx') {
          if (args) {
            return '⟨' + phrase + '|' + Object.keys(args).join('·') + '⟩'
          }
      Severity: Minor
      Found in server.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 getVerdict has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      const getVerdict = async (user) => {
        const username = user.screen_name
        console.log('USERNAME', username, user)
      
        if (user.suspended) return { verdict: 'upheld', because: 'you are suspended from Twitter' }
      Severity: Minor
      Found in routes/twitter.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

      Avoid deeply nested control flow statements.
      Open

                  if (newbooks) booklist.save(books)
      Severity: Major
      Found in routes/books.js - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

            return __('fallback', { content: translation })
        Severity: Major
        Found in server.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            if (await isFollowing('zuzakistan', username)) return { verdict: 'overturned', because: 'you have been vouched for' }
          Severity: Major
          Found in routes/twitter.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return { verdict: 'referred', because: 'you were probably blocked manually' }
            Severity: Major
            Found in routes/twitter.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                if (await isFollowing('lgballiance', username)) return { verdict: 'overturned', because: 'you have been vouched for' }
              Severity: Major
              Found in routes/twitter.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return next()
                Severity: Major
                Found in routes/auth.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    if (await isFollowing(username, 'countdankulatv')) return { verdict: 'upheld', because: 'the reason you were originally blocked is still true' }
                  Severity: Major
                  Found in routes/twitter.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      if (await isFollowing(username, 'lgballiance')) return { verdict: 'overturned', because: 'you were likely blocked in error' }
                    Severity: Major
                    Found in routes/twitter.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                        return translation
                      Severity: Major
                      Found in server.js - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language