srveit/mechanize-js

View on GitHub

Showing 18 of 28 total issues

Function newAgent has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

export function newAgent() {
  let logDir
  let userAgent = USER_AGENTS.Mechanize

  const agent = {}
Severity: Minor
Found in lib/mechanize/agent.js - About 1 day 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 newAgent has 219 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function newAgent() {
  let logDir
  let userAgent = USER_AGENTS.Mechanize

  const agent = {}
Severity: Major
Found in lib/mechanize/agent.js - About 1 day to fix

    Function newForm has 194 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function newForm(page, node) {
      const fields = []
      const form = {}
      const action = nodeAttr(node, 'action')
      const boundary = randomString(20)
    Severity: Major
    Found in lib/mechanize/form.js - About 7 hrs to fix

      Function initializeFields has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const initializeFields = () => {
          if (node) {
            search(node, '//input').forEach((node) => {
              const type = (nodeAttr(node, 'type') || 'text').toLocaleLowerCase()
              switch (type) {
      Severity: Major
      Found in lib/mechanize/form.js - About 2 hrs to fix

        Function newForm has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        export function newForm(page, node) {
          const fields = []
          const form = {}
          const action = nodeAttr(node, 'action')
          const boundary = randomString(20)
        Severity: Minor
        Found in lib/mechanize/form.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 fetchPage has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const fetchPage = async (options) => {
            const reqOptions = await requestOptions(options)
            const uri = reqOptions.uri
            const response = await fetch(uri, reqOptions)
        
        
        Severity: Major
        Found in lib/mechanize/agent.js - About 2 hrs to fix

          File form.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { newButton } from './form/button.js'
          import { newCheckbox } from './form/checkbox.js'
          import { newField } from './form/field.js'
          import { newFileUpload } from './form/file_upload.js'
          import { newHidden } from './form/hidden.js'
          Severity: Minor
          Found in lib/mechanize/form.js - About 2 hrs to fix

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

            export function newRadioButton(node, form) {
              const field = newField(node)
              let checked = Boolean(field.getAttribute('checked'))
              const fieldType = 'radioButton'
              const uncheckPeers = () =>
            Severity: Minor
            Found in lib/mechanize/form/radio_button.js - About 1 hr to fix

              Function newSubmit has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function newSubmit(node, initialValue) {
                const button = newButton(node, initialValue)
                const fieldType = 'submit'
                const formAction = button.getAttribute('formaction')
                const formTarget = button.getAttribute('formtarget')
              Severity: Minor
              Found in lib/mechanize/form/submit.js - About 1 hr to fix

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

                export function newLink(node, page) {
                  const agent = page.agent
                  const link = {}
                  const href = nodeAttr(node, 'href')
                  const relVal = nodeAttr(node, 'rel')
                Severity: Minor
                Found in lib/mechanize/page/link.js - About 1 hr to fix

                  Function newImageButton has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function newImageButton(node, initialValue) {
                    const button = newSubmit(node, initialValue)
                    let theX, theY
                    const fieldType = 'imageButton'
                  
                  
                  Severity: Minor
                  Found in lib/mechanize/form/image_button.js - About 1 hr to fix

                    Function requestHeaders has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      const requestHeaders = async (options) => {
                        const headers = {
                          'User-Agent': userAgent,
                          Accept: '*/*',
                          connection: 'keep-alive',
                    Severity: Minor
                    Found in lib/mechanize/agent.js - About 1 hr to fix

                      Function newFileUpload has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function newFileUpload(node, initialFilename) {
                        let theFilename = unescape(initialFilename)
                        let theMimeType
                        const field = newField(node)
                        const fieldType = 'fileUpload'
                      Severity: Minor
                      Found in lib/mechanize/form/file_upload.js - About 1 hr to fix

                        Function newField has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function newField(node, initialValue) {
                          let unescapedValue
                          const getAttribute = (name) => nodeAttr(node, name)
                          const disabled = Boolean(getAttribute('disabled'))
                          const domId = getAttribute('id')
                        Severity: Minor
                        Found in lib/mechanize/form/field.js - About 1 hr to fix

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

                          export function newKeygen(node, initialValue) {
                            const field = newField(node, initialValue)
                            let generatedKey
                            const fieldType = 'keygen'
                            const challenge = field.getAttribute('challenge')
                          Severity: Minor
                          Found in lib/mechanize/form/keygen.js - About 1 hr to fix

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

                            export function newPage({ uri, response, body, agent }) {
                              const page = {}
                              const doc = parseHtmlString(body)
                            
                              // eslint-disable-next-line
                            Severity: Minor
                            Found in lib/mechanize/page.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 newRadioButton has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function newRadioButton(node, form) {
                              const field = newField(node)
                              let checked = Boolean(field.getAttribute('checked'))
                              const fieldType = 'radioButton'
                              const uncheckPeers = () =>
                            Severity: Minor
                            Found in lib/mechanize/form/radio_button.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 newSubmit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function newSubmit(node, initialValue) {
                              const button = newButton(node, initialValue)
                              const fieldType = 'submit'
                              const formAction = button.getAttribute('formaction')
                              const formTarget = button.getAttribute('formtarget')
                            Severity: Minor
                            Found in lib/mechanize/form/submit.js - About 35 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

                            Severity
                            Category
                            Status
                            Source
                            Language