A11yWatch/a11ywatch-core

View on GitHub

Showing 96 of 188 total issues

Function createIframe has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const createIframe = async (
  req: FastifyContext["request"],
  res: FastifyContext["reply"]
) => {
  const baseUrl = req.query["url"] || req.query["websiteUrl"];
Severity: Minor
Found in src/core/controllers/iframe.ts - About 35 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 getWebsitesPaging has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const getWebsitesPaging = async (
  { userId, limit = 3, offset = 0, insights = false },
  chain?: boolean
): Promise<Website[] | [Website[], any]> => {
  const webPages = (await websitesCollection
Severity: Minor
Found in src/core/controllers/websites/find/get.ts - About 35 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 collectionUpsert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const collectionUpsert = async (
  source: any,
  [collection, shouldUpdate, shouldDelete]: [
    Collection<Document>,
    boolean | "upsert" | "many",
Severity: Minor
Found in src/core/utils/collection-upsert.ts - About 35 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 downloadToExcel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const downloadToExcel = async (
  _req: FastifyContext["request"],
  res: FastifyContext["reply"],
  data: Issue | any
) => {
Severity: Minor
Found in src/core/utils/download-to-excel.ts - About 35 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 scanSimple has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const scanSimple = 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 35 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 getUserFromToken has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const getUserFromToken = (
  bearerToken?: string
):
  | null
  | (Jwt & {
Severity: Minor
Found in src/core/utils/get-user.ts - About 35 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

Avoid too many return statements within this function.
Open

  return user;
Severity: Major
Found in src/core/utils/get-user-data.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return res.status(200).send(verifiedProps);
    Severity: Major
    Found in src/web/routes_groups/dns-verify.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

        return await collection.updateOne(
          queryParams,
          { $set: source },
          {
            upsert: shouldUpdate === "upsert",
      Severity: Major
      Found in src/core/utils/collection-upsert.ts - About 30 mins to fix

        Function setAuthRoutes has a Cognitive Complexity of 6 (exceeds 5 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: Minor
        Found in src/web/routes_groups/auth.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 getServerConfig has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const getServerConfig = (
          extra?: ApolloServerFastifyConfig
        ): ApolloServerFastifyConfig => {
          const schema = createScheme();
        
        
        Severity: Minor
        Found in src/apollo-server.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 initDbConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const initDbConnection = async (dbconnection?: string) => {
          client = await createClient(dbconnection);
        
          if (client) {
            try {
        Severity: Minor
        Found in src/database/client.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 responseWrap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const responseWrap = async (res: FastifyContext["reply"], source) => {
          const { callback, userId } = source ?? {};
        
          let message = HttpMessage.Ok;
          let code = StatusCode.Ok;
        Severity: Minor
        Found in src/web/response.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 watcherCrawl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const watcherCrawl = async (
          {
            url,
            userId,
            scan = false,
        Severity: Minor
        Found in src/core/actions/accessibility/watcher_crawl.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 getHostName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getHostName = (url: string) => {
          if (!url) {
            return "";
          }
          let q = decodeURIComponent(url);
        Severity: Minor
        Found in src/core/utils/get-host.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 statusBadge has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const statusBadge = async (
          req: FastifyContext["request"],
          res: FastifyContext["reply"]
        ) => {
          const domain = (req.params as any)?.domain?.replace(".svg", "");
        Severity: Minor
        Found in src/web/routes/resources/badge.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

        Severity
        Category
        Status
        Source
        Language