A11yWatch/a11ywatch-core

View on GitHub

Showing 96 of 188 total issues

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

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

    Function websiteWatch has a Cognitive Complexity of 12 (exceeds 5 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

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

    export const allowedNext = (
      token: string,
      req: FastifyContext["request"],
      res: FastifyContext["reply"],
      mediaType?: "html" | "json"
    Severity: Minor
    Found in src/core/utils/get-user-data.ts - About 1 hr to fix

      Function registerApp has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const registerApp = async (app: FastifyInstance) => {
        await app.register(cors, {
          origin: true,
        });
      
      
      Severity: Minor
      Found in src/web/register.ts - About 1 hr to fix

        Function onAuthGithub has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const onAuthGithub = (requestToken: string): Promise<any> => {
          return new Promise((resolve, reject) => {
            // TODO: shape with ttsc
            const data = JSON.stringify({
              client_id: clientID,
        Severity: Minor
        Found in src/web/routes_groups/auth.ts - About 1 hr to fix

          Function createServer has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const createServer = async () => {
            const websiteProto = await loadProto(); // crawler handling proto
            const coreProto = await loadProto("apicore.proto");
          
            server = new Server();
          Severity: Minor
          Found in src/proto/website-server.ts - About 1 hr to fix

            Function getAnalyticsPaging has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export const getAnalyticsPaging = async (
              params,
              chain?: boolean
            ): Promise<[Analytic[], Collection<Document>] | Analytic[]> => {
              const { userId, domain, limit = 20, offset = 0, all = false } = params ?? {};
            Severity: Minor
            Found in src/core/controllers/analytics/index.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 runUserChecks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export const runUserChecks = async ({
              userId,
              user,
              collection,
            }: {
            Severity: Minor
            Found in src/core/controllers/users/update/reset.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 verifyUserSend has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export const verifyUserSend = async ({
              userId,
              confirmedOnly = false, // confirmed only requires user id - non marketing sending.
              sendEmail = false, // conditional to determine email sending. Without having to use conditionals.
            }: VerifySend) => {
            Severity: Minor
            Found in src/core/messagers/verify.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 setDnsVerifyRoutes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export const setDnsVerifyRoutes = (app: FastifyInstance) => {
              app.get("/api/website/dns", async (req, res) => {
                const userId = validateUserRequest(req);
            
                // check to see if dns if verified
            Severity: Minor
            Found in src/web/routes_groups/dns-verify.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 getUserFromApiScan has a Cognitive Complexity of 11 (exceeds 5 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

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

            export const coreCrawl = async (call: ServerCallStreaming) => {
              const { authorization, url, subdomains, tld, sitemap } = call.request;
              const userNext = getUserFromToken(authorization); // get current user
              const userId = userNext?.payload?.keyid;
            
            
            Severity: Minor
            Found in src/proto/calls/core-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

            Function getWebsiteReport has a Cognitive Complexity of 11 (exceeds 5 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

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

            const sendMailMultiPage = async ({
              userId,
              data,
              domain,
              sendEmail = true,
            Severity: Minor
            Found in src/core/messagers/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

            Function coreCrawl has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const coreCrawl = async (call: ServerCallStreaming) => {
              const { authorization, url, subdomains, tld, sitemap } = call.request;
              const userNext = getUserFromToken(authorization); // get current user
              const userId = userNext?.payload?.keyid;
            
            
            Severity: Minor
            Found in src/proto/calls/core-crawl.ts - About 1 hr to fix

              Function getWebParams has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const getWebParams = (req: FastifyContext["request"]) => {
                const url = paramParser(req, "url");
                const customHeaders = paramParser(req, "customHeaders");
                const mobile = paramParser(req, "mobile");
                const pageInsights = paramParser(req, "pageInsights");
              Severity: Minor
              Found in src/web/params/web.ts - About 1 hr to fix

                Function getPageActionsPaging has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                export const getPageActionsPaging = async (
                  {
                    userId,
                    domain,
                    url,
                Severity: Minor
                Found in src/core/controllers/page-actions/page-actions.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 crawlWebsite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  crawlWebsite: async (_, { url }, context) => {
                    if (!url) {
                      return {
                        website: null,
                        code: StatusCode.NotFound,
                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

                Severity
                Category
                Status
                Source
                Language