Showing 8 of 17 total issues
Function onRequestPost
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const onRequestPost: PagesFunction<Env> = async function (context) {
const headers = context.request.headers
const input: CreateUrlFormData = convertFormDataToJson(await context.request.formData()) as CreateUrlFormData
const requestDetails = {
short: input.short,
Function onRequestPost
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
export const onRequestPost: PagesFunction<Env> = async function (context) {
const headers = context.request.headers
const input: CreateUrlFormData = convertFormDataToJson(await context.request.formData()) as CreateUrlFormData
const requestDetails = {
short: input.short,
- 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 onRequestDelete
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const onRequestDelete: PagesFunction<Env> = async function (context) {
const headers = context.request.headers
const input: DeleteUrlFormData = convertFormDataToJson(await context.request.formData()) as DeleteUrlFormData
const requestDetails = {
short: input.short,
Function setupDataTable
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
const setupDataTable = () => {
listTable = $('#list').DataTable({
ajax: 'url',
columns: [{ data: 's' }, { data: 'l' }, { data: 'c' }],
columnDefs: [
Function getUrls
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const getUrls = async function (
context: any,
orderBy?: object,
limit?: number,
offset?: number
- 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
Avoid too many return
statements within this function. Open
return new Response(output, {
status: returnStatus,
headers: DEFAULT_RESPONSE_HEADERS
})
Function onRequestDelete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const onRequestDelete: PagesFunction<Env> = async function (context) {
const headers = context.request.headers
const input: DeleteUrlFormData = convertFormDataToJson(await context.request.formData()) as DeleteUrlFormData
const requestDetails = {
short: input.short,
- 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 setupDataTable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
const setupDataTable = () => {
listTable = $('#list').DataTable({
ajax: 'url',
columns: [{ data: 's' }, { data: 'l' }, { data: 'c' }],
columnDefs: [
- 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"