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 = {}
- Read upRead up
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 = {}
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)
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) {
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)
- Read upRead up
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)
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'
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 = () =>
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')
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')
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'
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',
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'
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')
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')
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
- Read upRead up
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 = () =>
- Read upRead up
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')
- Read upRead up
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"