A11yWatch/a11ywatch-core

View on GitHub

Showing 96 of 188 total issues

Function crawlMultiSiteWithEvent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const crawlMultiSiteWithEvent = (
  props: CrawlParams
): Promise<CrawlMultiSite> => {
  const { url, userId, subdomains, tld, agent, proxy } = props;

Severity: Minor
Found in src/core/utils/multi-site.ts - About 1 hr to fix

    Function createIframe has 27 lines of code (exceeds 25 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 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

        if (
          (typeof proxy !== "undefined" && !proxy) ||
          (proxy &&
            typeof proxy === "string" &&
            (proxy.startsWith("http") ||
      Severity: Major
      Found in src/core/controllers/websites/update/update-website.ts - About 1 hr to fix

        Function AnalyticsController has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const AnalyticsController = ({ user } = { user: null }) => ({
          getCollection: analyticsCollection,
          getWebsite: async (
            { pageUrl, userId, domain, bypass }: BaseParams & { bypass?: boolean },
            chain?: boolean
        Severity: Minor
        Found in src/core/controllers/analytics/index.ts - About 55 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 websiteShape has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        const websiteShape = (source: any) => {
          let website;
        
          if ("website" in source) {
            website = source?.website;
        Severity: Minor
        Found in src/core/utils/shapes/website-gql.ts - About 55 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 websiteSearchParams has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function websiteSearchParams({
          userId,
          url,
          pageUrl,
          domain,
        Severity: Minor
        Found in src/core/utils/filters/website.ts - About 55 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 getPages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getPages = async (
          { domain, userId, url }: { domain?: string; userId?: number; url?: string },
          chain?: boolean
        ) => {
          if (!pagesCollection) {
        Severity: Minor
        Found in src/core/controllers/pages/find/domains.ts - About 55 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 getDataUntil has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        const getDataUntil = async (
          baseProps: ScoreProps & { resolve: Resolver },
          offset?: number,
          prevIssuesInfo?: any
        ): Promise<void> => {
        Severity: Minor
        Found in src/core/controllers/pages/update/utils/domain.ts - About 55 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 getIssue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getIssue = async (
          { url, pageUrl, userId, noRetries }: any,
          chain?: boolean
        ) => {
          const queryUrl = decodeURIComponent(String(url || pageUrl));
        Severity: Minor
        Found in src/core/controllers/issues/find/index.ts - About 55 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 loadProto has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export const loadProto = async (
          target: string = "website.proto",
          retry?: boolean
        ) => {
          try {
        Severity: Minor
        Found in src/proto/website.ts - About 45 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 removeWebsite has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export const removeWebsite = async ({
          userId,
          url = "",
          domain = "",
          deleteMany = false,
        Severity: Minor
        Found in src/core/controllers/websites/remove/remove.ts - About 45 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 rebindConcurrency has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const rebindConcurrency = async () => {
          const newLimit = getCWLimit(crawlingSet.size || 1);
        
          for (const item of crawlingSet.values()) {
            const itemEvent = item && item?.event;
        Severity: Minor
        Found in src/event/crawl-tracking.ts - About 45 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 getPageSpeedPaging has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getPageSpeedPaging = async (p, chain?: boolean) => {
          const { userId, domain, limit = 20, offset = 0, all = false } = p ?? {};
        
          let params = {};
        
        
        Severity: Minor
        Found in src/core/controllers/page-speed/main.ts - About 45 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 crawlProcessed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const crawlProcessed = (target) => {
          setImmediate(async () => {
            // process a new item tracking count
            const key = getKey(target.domain, target.pages, target.user_id);
        
        
        Severity: Minor
        Found in src/event/crawl-tracking.ts - About 45 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 allowedNext has a Cognitive Complexity of 8 (exceeds 5 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 45 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 websiteFormatter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const websiteFormatter = (source: any) => {
          const { data, website, ...rest } = source;
        
          const webPage = data ? data : website;
        
        
        Severity: Minor
        Found in src/core/utils/shapes/website-gql.ts - About 45 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

        Consider simplifying this complex logical expression.
        Open

          if (typeof userId !== undefined && userId !== null) {
            const [user] = await UsersController().getUser({
              id: userId,
            });
        
        
        Severity: Major
        Found in src/core/graph/queries/user.ts - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (passwordMatch || googleId || githubId) {
                let keyid = user?.id;
                let updateCollectionProps = {};
          
                // create a new user
          Severity: Major
          Found in src/core/controllers/users/set/create.ts - About 40 mins to fix

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

            export const user = async (_, { id, password }, ctx) => {
              const { userId, audience } = getPayLoad(ctx, {
                id,
                password,
              });
            Severity: Minor
            Found in src/core/graph/queries/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

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

            export const issuesResultsTemplate: IssuesResultsFound = (
              data,
              headingElement = "h1",
              hideFooter = false,
              freeAccount = true
            Severity: Minor
            Found in src/core/email_templates/issues-found.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

            Severity
            Category
            Status
            Source
            Language