Showing 96 of 188 total issues
Function updateWebsite
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
export const updateWebsite = async ({
userId,
url,
pageHeaders,
pageInsights,
- Read upRead up
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 255 lines of code (exceeds 25 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> => {
Function initServer
has 233 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function initServer(): Promise<HttpServer[]> {
let serverCleanup; // cleanup the ws server
const gqlServerConfig = getServerConfig({
plugins: [
{
Function addPaymentSubscription
has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring. Open
export const addPaymentSubscription = async ({
keyid,
email: emailP,
stripeToken, // contains the plan for the mutation - todo: split param off the stripe token
yearly,
- Read upRead up
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 setAuthRoutes
has 184 lines of code (exceeds 25 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,
Function addWebsite
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
export const addWebsite = async ({
userId,
url: urlMap,
customHeaders,
// audience,
- Read upRead up
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 scanAuthenticated
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
export const scanAuthenticated = async (
req: FastifyContext["request"],
res: FastifyContext["reply"]
) => {
const baseUrl = paramParser(req, "websiteUrl") || paramParser(req, "url");
- Read upRead up
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 UsersController
has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring. Open
export const UsersController: UserControllerType = (
{ user: _user } = { user: null }
) => ({
getCollection: usersCollection,
getUser,
- Read upRead up
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 createUser
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
export const createUser = async ({
email,
password,
googleId,
githubId: ghID,
- Read upRead up
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 stripeProductId
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
export const stripeProductId = (plan: string, yearly?: boolean) => {
const q = (plan && typeof plan === "string" && plan.toUpperCase()) || "";
let product = "";
switch (q) {
- Read upRead up
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
File crawl.ts
has 358 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { sourceBuild } from "@a11ywatch/website-source-builder";
import { emailMessager } from "../../messagers";
import { pubsub } from "../../../database/pubsub";
import { ISSUE_ADDED } from "../../static";
import { collectionUpsert } from "../../utils";
File app.ts
has 350 lines of code (exceeds 250 allowed). Consider refactoring. Open
import fastify, { FastifyInstance } from "fastify";
import { ApolloServer } from "apollo-server-fastify";
import { configureAgent } from "node-iframe";
import { WebSocketServer } from "ws";
import { useServer } from "graphql-ws/lib/use/ws";
Function getCrawlConfig
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
export const getCrawlConfig = async ({
id,
role,
url,
tld,
- Read upRead up
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 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const issuesResultsTemplate: IssuesResultsFound = (
data,
headingElement = "h1",
hideFooter = false,
freeAccount = true
Function stripeProductId
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const stripeProductId = (plan: string, yearly?: boolean) => {
const q = (plan && typeof plan === "string" && plan.toUpperCase()) || "";
let product = "";
switch (q) {
Function scanAuthenticated
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const scanAuthenticated = async (
req: FastifyContext["request"],
res: FastifyContext["reply"]
) => {
const baseUrl = paramParser(req, "websiteUrl") || paramParser(req, "url");
Function stripeHook
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const stripeHook = async (req, res) => {
let event: Stripe.Event;
try {
event = await stripe.webhooks.constructEventAsync(
Function crawlHttpStream
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const crawlHttpStream = (
props: CrawlParams,
res: FastifyContext["reply"],
removeTrailing: boolean = true // disable for high performance output
): Promise<boolean> => {
Function getReport
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const getReport = async (url: string, userId?: number) => {
if (!url) {
return { website: undefined };
}
const authenticated = typeof userId !== "undefined";
Function setListRoutes
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const setListRoutes = (app: FastifyInstance) => {
// paginated retrieve websites from the database.
app.get("/api/list/website", async (req, res) => {
const { userId, offset, limit } = getBaseParamsList(req);