A11yWatch/a11ywatch-core

View on GitHub

Showing 188 of 188 total issues

Function getDataUntil has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getDataUntil = async (
  baseProps: ScoreProps & { resolve: Resolver },
  offset?: number,
  prevIssuesInfo?: any
): Promise<void> => {
Severity: Major
Found in src/core/controllers/pages/update/utils/domain.ts - About 2 hrs to fix

    Function getReport has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getReport = async (url: string, userId?: number) => {
      if (!url) {
        return { website: undefined };
      }
      const authenticated = typeof userId !== "undefined";
    Severity: Minor
    Found in src/core/controllers/reports/read.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 crawlPage has a Cognitive Complexity of 18 (exceeds 5 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: Minor
    Found in src/core/actions/accessibility/crawl.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

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

    export const scanStart = async (
      call: ServerWritableStream<{ domain: string; user_id: number }, {}>,
      callback: sendUnaryData<any>
    ) => {
      crawlTrackingEmitter.emit("crawl-start", call.request);
    Severity: Major
    Found in src/proto/calls/scan-start.ts and 1 other location - About 2 hrs to fix
    src/proto/calls/scan-end.ts on lines 5..11

    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 81.

    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 const scanEnd = async (
      call: ServerWritableStream<{ domain: string; user_id: number }, {}>,
      callback: sendUnaryData<any>
    ) => {
      crawlTrackingEmitter.emit("crawl-complete", call.request);
    Severity: Major
    Found in src/proto/calls/scan-end.ts and 1 other location - About 2 hrs to fix
    src/proto/calls/scan-start.ts on lines 5..11

    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 81.

    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 verifyUser has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    const verifyUser = async ({
      password,
      email,
      googleId,
      githubId,
    Severity: Minor
    Found in src/core/controllers/users/update/verify.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 stripeHook has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    export const stripeHook = async (req, res) => {
      let event: Stripe.Event;
    
      try {
        event = await stripe.webhooks.constructEventAsync(
    Severity: Minor
    Found in src/web/routes_groups/stripe.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 priceHandler has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function downloadToExcel has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const downloadToExcel = async (
        _req: FastifyContext["request"],
        res: FastifyContext["reply"],
        data: Issue | any
      ) => {
      Severity: Major
      Found in src/core/utils/download-to-excel.ts - About 2 hrs to fix

        Function roleHandler has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const roleHandler = (plan: string) => {
          const q = (plan && typeof plan === "string" && plan.toUpperCase()) || "";
          let role = 0;
        
          switch (q) {
        Severity: Minor
        Found in src/core/utils/price-handler.ts - About 1 hr to fix

          Function crawlStream has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const crawlStream = async (
            req: FastifyContext["request"],
            res: FastifyContext["reply"],
            slim?: boolean
          ) => {
          Severity: Minor
          Found in src/core/streams/crawl.ts - About 1 hr to fix

            Function crawlHttpStreamSlim has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const crawlHttpStreamSlim = (
              props: CrawlParams,
              res: FastifyContext["reply"],
              removeTrailing: boolean = true
            ): Promise<boolean> => {
            Severity: Minor
            Found in src/core/utils/crawl-stream-slim.ts - About 1 hr to fix

              Function updateScanAttempt has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              export const updateScanAttempt = async ({
                userId,
                user,
                collection,
              }: {
              Severity: Minor
              Found in src/core/controllers/users/update/scan-attempt.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

              Function scanWebsite has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                scanWebsite: async (parent, args, context, info) => {
                  const { url } = args;
                  const { keyid } = context.user?.payload || defaultPayload;
                  const unauth = typeof keyid === "undefined";
              
              
              Severity: Minor
              Found in src/core/mutations.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

              Function getWebsiteReport has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const getWebsiteReport = async (
                req: FastifyContext["request"],
                res: FastifyContext["reply"]
              ) => {
                const download = paramParser(req, "download");
              Severity: Minor
              Found in src/web/routes/data/website.ts - About 1 hr to fix

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

                export const issues = async (_, { url: pageUrl, ...props }, context) => {
                  const userId = getPayLoad(context, props)?.userId;
                
                  return await IssuesController().getIssues({
                    userId,
                Severity: Major
                Found in src/core/graph/queries/issues.ts and 1 other location - About 1 hr to fix
                src/core/graph/queries/pages.ts on lines 5..12

                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 72.

                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 const pages = async (_, { domain, ...props }, context) => {
                  const userId = getPayLoad(context, props)?.userId;
                
                  return await PagesController().getPages({
                    userId,
                Severity: Major
                Found in src/core/graph/queries/pages.ts and 1 other location - About 1 hr to fix
                src/core/graph/queries/issues.ts on lines 15..22

                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 72.

                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 scanWebsite has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  scanWebsite: async (parent, args, context, info) => {
                    const { url } = args;
                    const { keyid } = context.user?.payload || defaultPayload;
                    const unauth = typeof keyid === "undefined";
                
                
                Severity: Minor
                Found in src/core/mutations.ts - About 1 hr to fix

                  Function pageUpdate has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const pageUpdate = async (
                    call: ServerWritableStream<
                      { domain: string; url: string; user_id: number; insight: any },
                      {}
                    >,
                  Severity: Minor
                  Found in src/proto/calls/page-update.ts - About 1 hr to fix

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

                      sortWebsites: async (_, { order }, context) => {
                        const { keyid } = context.user?.payload || defaultPayload;
                    
                        return await WebsitesController().sortWebsites({
                          userId: keyid,
                    Severity: Major
                    Found in src/core/mutations.ts and 2 other locations - About 1 hr to fix
                    src/core/mutations.ts on lines 230..237
                    src/core/mutations.ts on lines 244..251

                    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 71.

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language