A11yWatch/a11ywatch-core

View on GitHub

Showing 188 of 188 total issues

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

  confirmEmail: async (_, { email }, context) => {
    const { keyid } = context.user?.payload || defaultPayload;

    return await UsersController().confirmEmail({
      email,
Severity: Major
Found in src/core/mutations.ts and 2 other locations - About 1 hr to fix
src/core/mutations.ts on lines 244..251
src/core/mutations.ts on lines 252..259

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

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

  toggleAlert: async (_, { alertEnabled }, context) => {
    const { keyid } = context.user?.payload || defaultPayload;

    return await UsersController().toggleAlert({
      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 252..259

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

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

    setImmediate(
      async () =>
        await watcherCrawl({
          url,
          userId,
Severity: Major
Found in src/core/utils/crawl-stream.ts and 1 other location - About 1 hr to fix
src/core/utils/crawl-stream-slim.ts on lines 61..74

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

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

    setImmediate(
      async () =>
        await watcherCrawl({
          url,
          userId,
Severity: Major
Found in src/core/utils/crawl-stream-slim.ts and 1 other location - About 1 hr to fix
src/core/utils/crawl-stream.ts on lines 88..101

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

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 {
  ADD_FREE_MAX_ERROR,
  AUTH_ERROR,
  GENERAL_ERROR,
  EMAIL_ERROR,
Severity: Major
Found in src/core/strings/index.ts and 1 other location - About 1 hr to fix
src/database/index.ts on lines 1..15

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

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 {
  connect,
  client,
  initDbConnection,
  closeDbConnection,
Severity: Major
Found in src/database/index.ts and 1 other location - About 1 hr to fix
src/core/strings/index.ts on lines 1..15

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

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

        await pubsub.publish(ISSUE_ADDED, {
          issueAdded: {
            domain: webPage.domain,
            url: webPage.url,
            pageLoadTime: webPage.pageLoadTime,
Severity: Major
Found in src/core/actions/accessibility/crawl.ts and 1 other location - About 1 hr to fix
src/core/actions/accessibility/crawl.ts on lines 357..368

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

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

  const responseData = {
    data: {
      domain: webPage.domain,
      url: webPage.url,
      pageLoadTime: webPage.pageLoadTime,
Severity: Major
Found in src/core/actions/accessibility/crawl.ts and 1 other location - About 1 hr to fix
src/core/actions/accessibility/crawl.ts on lines 339..350

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

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 scanSimple has 41 lines of code (exceeds 25 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 1 hr to fix

    Function websiteWatch has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function websiteWatch(pages: Website[] = []): Promise<void> {
      for (const website of pages) {
        const { userId, url, subdomains, tld, ua, proxy, monitoringEnabled } =
          website;
    
    
    Severity: Minor
    Found in src/core/controllers/websites/watch-pages.ts - About 1 hr to fix

      Function getPagesPaging has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      export const getPagesPaging = async (
        {
          userId,
          domain,
          limit = 5,
      Severity: Minor
      Found in src/core/controllers/pages/find/domains.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 crawlStream has a Cognitive Complexity of 13 (exceeds 5 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

      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 6 locations. Consider refactoring.
      Open

      export const websiteRemoved = {
        subscribe: withFilter(
          () => pubsub.asyncIterator(WEBSITE_REMOVED),
          (payload: any, _: any, context: any) =>
            payload?.websiteRemoved?.userId === context?.userId
      Severity: Major
      Found in src/core/graph/subscriptions/website-removed.ts and 5 other locations - About 1 hr to fix
      src/core/graph/subscriptions/crawl-complete.ts on lines 5..11
      src/core/graph/subscriptions/email-verified.ts on lines 5..11
      src/core/graph/subscriptions/issue-added.ts on lines 5..11
      src/core/graph/subscriptions/lighthouse.ts on lines 5..11
      src/core/graph/subscriptions/website-added.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 66.

      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 6 locations. Consider refactoring.
      Open

      export const crawlComplete = {
        subscribe: withFilter(
          () => pubsub.asyncIterator(CRAWL_COMPLETE),
          (payload: any, _: any, context: any) =>
            payload?.crawlComplete?.userId === context?.userId
      Severity: Major
      Found in src/core/graph/subscriptions/crawl-complete.ts and 5 other locations - About 1 hr to fix
      src/core/graph/subscriptions/email-verified.ts on lines 5..11
      src/core/graph/subscriptions/issue-added.ts on lines 5..11
      src/core/graph/subscriptions/lighthouse.ts on lines 5..11
      src/core/graph/subscriptions/website-added.ts on lines 5..11
      src/core/graph/subscriptions/website-removed.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 66.

      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 6 locations. Consider refactoring.
      Open

      export const emailVerified = {
        subscribe: withFilter(
          () => pubsub.asyncIterator(EMAIL_VERIFIED),
          (payload: any, _: any, context: any) =>
            payload?.emailVerified?.userId === context?.userId
      Severity: Major
      Found in src/core/graph/subscriptions/email-verified.ts and 5 other locations - About 1 hr to fix
      src/core/graph/subscriptions/crawl-complete.ts on lines 5..11
      src/core/graph/subscriptions/issue-added.ts on lines 5..11
      src/core/graph/subscriptions/lighthouse.ts on lines 5..11
      src/core/graph/subscriptions/website-added.ts on lines 5..11
      src/core/graph/subscriptions/website-removed.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 66.

      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 6 locations. Consider refactoring.
      Open

      export const lighthouseResult = {
        subscribe: withFilter(
          () => pubsub.asyncIterator(LIGHTHOUSE),
          (payload: any, _: any, context: any) =>
            payload?.lighthouseResult?.userId === context?.userId
      Severity: Major
      Found in src/core/graph/subscriptions/lighthouse.ts and 5 other locations - About 1 hr to fix
      src/core/graph/subscriptions/crawl-complete.ts on lines 5..11
      src/core/graph/subscriptions/email-verified.ts on lines 5..11
      src/core/graph/subscriptions/issue-added.ts on lines 5..11
      src/core/graph/subscriptions/website-added.ts on lines 5..11
      src/core/graph/subscriptions/website-removed.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 66.

      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 6 locations. Consider refactoring.
      Open

      export const websiteAdded = {
        subscribe: withFilter(
          () => pubsub.asyncIterator(WEBSITE_ADDED),
          (payload: any, _: any, context: any) =>
            payload?.websiteAdded?.userId === context?.userId
      Severity: Major
      Found in src/core/graph/subscriptions/website-added.ts and 5 other locations - About 1 hr to fix
      src/core/graph/subscriptions/crawl-complete.ts on lines 5..11
      src/core/graph/subscriptions/email-verified.ts on lines 5..11
      src/core/graph/subscriptions/issue-added.ts on lines 5..11
      src/core/graph/subscriptions/lighthouse.ts on lines 5..11
      src/core/graph/subscriptions/website-removed.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 66.

      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 6 locations. Consider refactoring.
      Open

      export const issueAdded = {
        subscribe: withFilter(
          () => pubsub.asyncIterator(ISSUE_ADDED),
          (payload: any, _: any, context: any) =>
            payload?.issueAdded?.userId === context?.userId
      Severity: Major
      Found in src/core/graph/subscriptions/issue-added.ts and 5 other locations - About 1 hr to fix
      src/core/graph/subscriptions/crawl-complete.ts on lines 5..11
      src/core/graph/subscriptions/email-verified.ts on lines 5..11
      src/core/graph/subscriptions/lighthouse.ts on lines 5..11
      src/core/graph/subscriptions/website-added.ts on lines 5..11
      src/core/graph/subscriptions/website-removed.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 66.

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

      export const getUserFromApiScan = async (
        token: string = "",
        _req: FastifyContext["request"],
        res: FastifyContext["reply"]
      ): Promise<User> => {
      Severity: Minor
      Found in src/core/utils/get-user-data.ts - About 1 hr to fix

        Function validateEmail has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        export const validateEmail = async ({ code }) => {
          if (code) {
            const [user, collection] = await getUser({ emailConfirmCode: code });
        
            if (user && isBefore(new Date(), new Date(user?.emailExpDate))) {
        Severity: Minor
        Found in src/core/controllers/users/update/validate-email.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

        Severity
        Category
        Status
        Source
        Language