A11yWatch/a11ywatch-core

View on GitHub

Showing 188 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          app.post("/api/register", registerLimiter, async (req, res) => {
            const allowed = await allowedNext(
              req?.headers?.authorization || req.cookies.jwt,
              req,
              res
        Severity: Major
        Found in src/web/routes_groups/auth.ts and 1 other location - About 6 hrs to fix
        src/web/routes_groups/auth.ts on lines 127..150

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 173.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          app.post("/api/login", limiter, async (req, res) => {
            const allowed = await allowedNext(
              req?.headers?.authorization || req.cookies.jwt,
              req,
              res
        Severity: Major
        Found in src/web/routes_groups/auth.ts and 1 other location - About 6 hrs to fix
        src/web/routes_groups/auth.ts on lines 103..126

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 173.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          switch (q) {
            case "L1": {
              role = 1;
              break;
            }
        Severity: Major
        Found in src/core/utils/price-handler.ts and 1 other location - About 6 hrs to fix
        src/core/utils/price-handler.ts on lines 6..52

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 168.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          switch (q) {
            case "L1": {
              price = 1400;
              break;
            }
        Severity: Major
        Found in src/core/utils/price-handler.ts and 1 other location - About 6 hrs to fix
        src/core/utils/price-handler.ts on lines 167..213

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 168.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export async function register(
          _,
          { email, password, googleId, githubId },
          context
        ) {
        Severity: Major
        Found in src/core/graph/mutations/authentication/register.ts and 1 other location - About 4 hrs to fix
        src/core/graph/mutations/authentication/login.ts on lines 6..27

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 133.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export async function login(
          _,
          { email, password, googleId, githubId },
          context
        ) {
        Severity: Major
        Found in src/core/graph/mutations/authentication/login.ts and 1 other location - About 4 hrs to fix
        src/core/graph/mutations/authentication/register.ts on lines 6..27

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 133.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          if (rules && Array.isArray(rules)) {
            for (let i = 0; i < rules.length; i++) {
              const rule = rules[i];
        
              // validate rule storing
        Severity: Major
        Found in src/core/controllers/websites/update/update-website.ts and 1 other location - About 4 hrs to fix
        src/core/controllers/websites/update/update-website.ts on lines 146..159

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 130.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          if (ignore && Array.isArray(ignore)) {
            for (let i = 0; i < ignore.length; i++) {
              const rule = ignore[i];
              // validate rule storing
              if (rule && typeof rule === "string" && rule.length < 200) {
        Severity: Major
        Found in src/core/controllers/websites/update/update-website.ts and 1 other location - About 4 hrs to fix
        src/core/controllers/websites/update/update-website.ts on lines 126..141

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 130.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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
            Severity
            Category
            Status
            Source
            Language