A11yWatch/a11ywatch-core

View on GitHub

Showing 96 of 188 total issues

Function updateWebsite has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

export const updateWebsite = async ({
  userId,
  url,
  pageHeaders,
  pageInsights,
Severity: Minor
Found in src/core/controllers/websites/update/update-website.ts - 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 crawlPage has 255 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const crawlPage = async (
  crawlConfig: CrawlConfig,
  sendEmail?: boolean, // determine if email should be sent based on results
  blockEvent?: boolean // block event from emitting to protect crawl interfere
): Promise<ResponseModel> => {
Severity: Major
Found in src/core/actions/accessibility/crawl.ts - About 1 day to fix

    Function initServer has 233 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function initServer(): Promise<HttpServer[]> {
      let serverCleanup; // cleanup the ws server
      const gqlServerConfig = getServerConfig({
        plugins: [
          {
    Severity: Major
    Found in src/app.ts - About 1 day to fix

      Function addPaymentSubscription has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
      Open

      export const addPaymentSubscription = async ({
        keyid,
        email: emailP,
        stripeToken, // contains the plan for the mutation - todo: split param off the stripe token
        yearly,
      Severity: Minor
      Found in src/core/controllers/users/update/payments.ts - 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 setAuthRoutes has 184 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const setAuthRoutes = (app: FastifyInstance) => {
        app.post("/api/register", registerLimiter, async (req, res) => {
          const allowed = await allowedNext(
            req?.headers?.authorization || req.cookies.jwt,
            req,
      Severity: Major
      Found in src/web/routes_groups/auth.ts - About 7 hrs to fix

        Function addWebsite has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
        Open

        export const addWebsite = async ({
          userId,
          url: urlMap,
          customHeaders,
          // audience,
        Severity: Minor
        Found in src/core/controllers/websites/set/add-website.ts - About 7 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 scanAuthenticated has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

        export const scanAuthenticated = async (
          req: FastifyContext["request"],
          res: FastifyContext["reply"]
        ) => {
          const baseUrl = paramParser(req, "websiteUrl") || paramParser(req, "url");
        Severity: Minor
        Found in src/web/routes/scan.ts - About 7 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 UsersController has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
        Open

        export const UsersController: UserControllerType = (
          { user: _user } = { user: null }
        ) => ({
          getCollection: usersCollection,
          getUser,
        Severity: Minor
        Found in src/core/controllers/users/users.ts - About 6 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 createUser has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

        export const createUser = async ({
          email,
          password,
          googleId,
          githubId: ghID,
        Severity: Minor
        Found in src/core/controllers/users/set/create.ts - About 6 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 stripeProductId has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

        export const stripeProductId = (plan: string, yearly?: boolean) => {
          const q = (plan && typeof plan === "string" && plan.toUpperCase()) || "";
          let product = "";
        
          switch (q) {
        Severity: Minor
        Found in src/core/utils/price-handler.ts - About 5 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

        File crawl.ts has 358 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { sourceBuild } from "@a11ywatch/website-source-builder";
        import { emailMessager } from "../../messagers";
        import { pubsub } from "../../../database/pubsub";
        import { ISSUE_ADDED } from "../../static";
        import { collectionUpsert } from "../../utils";
        Severity: Minor
        Found in src/core/actions/accessibility/crawl.ts - About 4 hrs to fix

          File app.ts has 350 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import fastify, { FastifyInstance } from "fastify";
          import { ApolloServer } from "apollo-server-fastify";
          import { configureAgent } from "node-iframe";
          import { WebSocketServer } from "ws";
          import { useServer } from "graphql-ws/lib/use/ws";
          Severity: Minor
          Found in src/app.ts - About 4 hrs to fix

            Function getCrawlConfig has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

            export const getCrawlConfig = async ({
              id,
              role,
              url,
              tld,
            Severity: Minor
            Found in src/core/streams/crawl-config.ts - About 4 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 issuesResultsTemplate has 97 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const issuesResultsTemplate: IssuesResultsFound = (
              data,
              headingElement = "h1",
              hideFooter = false,
              freeAccount = true
            Severity: Major
            Found in src/core/email_templates/issues-found.ts - About 3 hrs to fix

              Function stripeProductId has 93 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const stripeProductId = (plan: string, yearly?: boolean) => {
                const q = (plan && typeof plan === "string" && plan.toUpperCase()) || "";
                let product = "";
              
                switch (q) {
              Severity: Major
              Found in src/core/utils/price-handler.ts - About 3 hrs to fix

                Function scanAuthenticated has 84 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const scanAuthenticated = async (
                  req: FastifyContext["request"],
                  res: FastifyContext["reply"]
                ) => {
                  const baseUrl = paramParser(req, "websiteUrl") || paramParser(req, "url");
                Severity: Major
                Found in src/web/routes/scan.ts - About 3 hrs to fix

                  Function stripeHook has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const stripeHook = async (req, res) => {
                    let event: Stripe.Event;
                  
                    try {
                      event = await stripe.webhooks.constructEventAsync(
                  Severity: Major
                  Found in src/web/routes_groups/stripe.ts - About 3 hrs to fix

                    Function crawlHttpStream has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export const crawlHttpStream = (
                      props: CrawlParams,
                      res: FastifyContext["reply"],
                      removeTrailing: boolean = true // disable for high performance output
                    ): Promise<boolean> => {
                    Severity: Major
                    Found in src/core/utils/crawl-stream.ts - About 3 hrs to fix

                      Function getReport has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const getReport = async (url: string, userId?: number) => {
                        if (!url) {
                          return { website: undefined };
                        }
                        const authenticated = typeof userId !== "undefined";
                      Severity: Major
                      Found in src/core/controllers/reports/read.ts - About 2 hrs to fix

                        Function setListRoutes has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const setListRoutes = (app: FastifyInstance) => {
                          // paginated retrieve websites from the database.
                          app.get("/api/list/website", async (req, res) => {
                            const { userId, offset, limit } = getBaseParamsList(req);
                        
                        
                        Severity: Major
                        Found in src/web/routes_groups/list.ts - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language