bkimminich/juice-shop

View on GitHub

Showing 90 of 90 total issues

File server.js has 489 lines of code (exceeds 300 allowed). Consider refactoring.
Open

/*
 * Copyright (c) 2014-2020 Bjoern Kimminich.
 * SPDX-License-Identifier: MIT
 */
const startTime = Date.now()
Severity: Minor
Found in server.js - About 6 hrs to fix

    Function placeOrder has 148 lines of code (exceeds 30 allowed). Consider refactoring.
    Open

    module.exports = function placeOrder () {
      return (req, res, next) => {
        const id = req.params.id
        models.Basket.findOne({ where: { id }, include: [{ model: models.Product, paranoid: false }] })
          .then(async basket => {
    Severity: Major
    Found in routes/order.js - About 5 hrs to fix

      File 2faSpec.js has 381 lines of code (exceeds 300 allowed). Consider refactoring.
      Open

      /*
       * Copyright (c) 2014-2020 Bjoern Kimminich.
       * SPDX-License-Identifier: MIT
       */
      
      
      Severity: Minor
      Found in test/api/2faSpec.js - About 3 hrs to fix

        File dataExportApiSpec.js has 354 lines of code (exceeds 300 allowed). Consider refactoring.
        Open

        /*
         * Copyright (c) 2014-2020 Bjoern Kimminich.
         * SPDX-License-Identifier: MIT
         */
        
        
        Severity: Minor
        Found in test/api/dataExportApiSpec.js - About 3 hrs to fix

          Function observeMetrics has 86 lines of code (exceeds 30 allowed). Consider refactoring.
          Open

          exports.observeMetrics = function observeMetrics () {
            const app = config.get('application.customMetricsPrefix')
            const intervalCollector = Prometheus.collectDefaultMetrics({ timeout: 5000 })
            register.setDefaultLabels({ app })
          
          
          Severity: Major
          Found in routes/metrics.js - About 3 hrs to fix

            File configValidationSpec.js has 329 lines of code (exceeds 300 allowed). Consider refactoring.
            Open

            /*
             * Copyright (c) 2014-2020 Bjoern Kimminich.
             * SPDX-License-Identifier: MIT
             */
            
            
            Severity: Minor
            Found in test/server/configValidationSpec.js - About 2 hrs to fix

              ScoreBoardComponent has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              @Component({
                selector: 'app-score-board',
                templateUrl: './score-board.component.html',
                styleUrls: ['./score-board.component.scss']
              })
              Severity: Minor
              Found in frontend/src/app/score-board/score-board.component.ts - About 2 hrs to fix

                Function ngOnInit has 66 lines of code (exceeds 30 allowed). Consider refactoring.
                Open

                  ngOnInit () {
                    this.spinner.show()
                
                    this.displayedDifficulties = localStorage.getItem('displayedDifficulties') ? JSON.parse(String(localStorage.getItem('displayedDifficulties'))) : [1]
                    this.showSolvedChallenges = localStorage.getItem('showSolvedChallenges') ? JSON.parse(String(localStorage.getItem('showSolvedChallenges'))) : true
                Severity: Major
                Found in frontend/src/app/score-board/score-board.component.ts - About 2 hrs to fix

                  Function status has a Cognitive Complexity of 20 (exceeds 7 allowed). Consider refactoring.
                  Open

                  module.exports.status = function status () {
                    return async (req, res, next) => {
                      if (!bot) {
                        res.status(200).json({
                          status: false,
                  Severity: Minor
                  Found in routes/chatbot.js - About 2 hrs 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 login has 64 lines of code (exceeds 30 allowed). Consider refactoring.
                  Open

                  module.exports = function login () {
                    function afterLogin (user, res, next) {
                      verifyPostLoginChallenges(user)
                      models.Basket.findOrCreate({ where: { UserId: user.data.id }, defaults: {} })
                        .then(([basket]) => {
                  Severity: Major
                  Found in routes/login.js - About 2 hrs to fix

                    File search-result.component.spec.ts has 313 lines of code (exceeds 300 allowed). Consider refactoring.
                    Open

                    /*
                     * Copyright (c) 2014-2020 Bjoern Kimminich.
                     * SPDX-License-Identifier: MIT
                     */
                    
                    
                    Severity: Minor
                    Found in frontend/src/app/search-result/search-result.component.spec.ts - About 2 hrs to fix

                      File verify.js has 313 lines of code (exceeds 300 allowed). Consider refactoring.
                      Open

                      /*
                       * Copyright (c) 2014-2020 Bjoern Kimminich.
                       * SPDX-License-Identifier: MIT
                       */
                      
                      
                      Severity: Minor
                      Found in routes/verify.js - About 2 hrs to fix

                        Function dataExport has 61 lines of code (exceeds 30 allowed). Consider refactoring.
                        Open

                        module.exports = function dataExport () {
                          return async (req, res, next) => {
                            const loggedInUser = insecurity.authenticatedUsers.get(req.headers.authorization.replace('Bearer ', ''))
                            if (loggedInUser && loggedInUser.data && loggedInUser.data.email && loggedInUser.data.id) {
                              const username = loggedInUser.data.username
                        Severity: Major
                        Found in routes/dataExport.js - About 2 hrs to fix

                          Function getLanguageList has 61 lines of code (exceeds 30 allowed). Consider refactoring.
                          Open

                          module.exports = function getLanguageList () { // TODO Refactor and extend to also load backend translations from /i18n/*json and calculate joint percentage/gauge
                            return (req, res, next) => {
                              const languages = []
                              let count = 0
                              let enContent
                          Severity: Major
                          Found in routes/languages.js - About 2 hrs to fix

                            Function databaseRelatedChallenges has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                            Open

                            exports.databaseRelatedChallenges = () => (req, res, next) => {
                              if (utils.notSolved(challenges.changeProductChallenge) && products.osaft) {
                                changeProductChallenge(products.osaft)
                              }
                              if (utils.notSolved(challenges.feedbackChallenge)) {
                            Severity: Minor
                            Found in routes/verify.js - About 2 hrs 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 changePassword has a Cognitive Complexity of 18 (exceeds 7 allowed). Consider refactoring.
                            Open

                            module.exports = function changePassword () {
                              return ({ query, headers, connection }, res, next) => {
                                const currentPassword = query.current
                                const newPassword = query.new
                                const repeatPassword = query.repeat
                            Severity: Minor
                            Found in routes/changePassword.js - About 2 hrs 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 ngAfterViewInit has 57 lines of code (exceeds 30 allowed). Consider refactoring.
                            Open

                              ngAfterViewInit () {
                                const products = this.productService.search('')
                                const quantities = this.quantityService.getAll()
                                forkJoin([quantities, products]).subscribe(([quantities, products]) => {
                                  let dataTable: TableEntry[] = []
                            Severity: Major
                            Found in frontend/src/app/search-result/search-result.component.ts - About 2 hrs to fix

                              File score-board.component.ts has 301 lines of code (exceeds 300 allowed). Consider refactoring.
                              Open

                              /*
                               * Copyright (c) 2014-2020 Bjoern Kimminich.
                               * SPDX-License-Identifier: MIT
                               */
                              
                              
                              Severity: Minor
                              Found in frontend/src/app/score-board/score-board.component.ts - About 2 hrs to fix

                                Function processQuery has 55 lines of code (exceeds 30 allowed). Consider refactoring.
                                Open

                                async function processQuery (user, req, res) {
                                  const username = user.username
                                  if (!username) {
                                    res.status(200).json({
                                      action: 'namequery',
                                Severity: Major
                                Found in routes/chatbot.js - About 2 hrs to fix

                                  Function restoreProgress has a Cognitive Complexity of 17 (exceeds 7 allowed). Consider refactoring.
                                  Open

                                  module.exports = function restoreProgress () {
                                    return ({ params }, res) => {
                                      const continueCode = params.continueCode
                                      const ids = hashids.decode(continueCode)
                                      if (utils.notSolved(challenges.continueCodeChallenge) && ids.indexOf(999) > -1) {
                                  Severity: Minor
                                  Found in routes/restoreProgress.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