shootismoke/backend

View on GitHub

Showing 4 of 6 total issues

Function receipts has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function receipts(_req: NowRequest, res: NowResponse): Promise<void> {
    try {
        await connectToDatabase(process.env.MONGODB_ATLAS_URI);

        const tickets = await PushTicket.find({
Severity: Minor
Found in src/api/receipts.ts - About 1 hr to fix

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

    export async function push(_req: NowRequest, res: NowResponse): Promise<void> {
        try {
            await connectToDatabase(process.env.MONGODB_ATLAS_URI);
    
            // Fetch all users to whom we should show a notification
    Severity: Minor
    Found in src/api/push.ts - About 1 hr to fix

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

      export async function expoMessageForUser(
          user: User & Document
      ): Promise<UserExpoMessage> {
          try {
              // Find the PM2.5 value at the user's last known station (universalId)
      Severity: Minor
      Found in src/push/provider.ts - About 1 hr to fix

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

        export async function handleReceipts(
            expo: Expo,
            receiptIds: string[],
            onOk: (receiptId: ExpoPushReceiptId, receipt: ExpoPushReceipt) => void,
            onError: (receiptId: ExpoPushReceiptId, receipt: ExpoPushReceipt) => void
        Severity: Minor
        Found in src/push/expo.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

        Severity
        Category
        Status
        Source
        Language