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,
Severity: Major
Found in functions/url.ts - About 4 hrs to fix

    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,
    Severity: Minor
    Found in functions/url.ts - 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 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,
    Severity: Major
    Found in functions/url.ts - About 2 hrs to fix

      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: [
      Severity: Minor
      Found in src/assets/js/app.js - About 2 hrs to fix

        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
        Severity: Minor
        Found in src/ts/data.ts - 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

        Avoid too many return statements within this function.
        Open

          return new Response(output, {
            status: returnStatus,
            headers: DEFAULT_RESPONSE_HEADERS
          })
        Severity: Major
        Found in functions/url.ts - About 30 mins to fix

          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,
          Severity: Minor
          Found in functions/url.ts - About 25 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 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: [
          Severity: Minor
          Found in src/assets/js/app.js - About 25 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