Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance setup.js for Improved Docker Compatibility #2447

Conversation

VanshikaSabharwal
Copy link

@VanshikaSabharwal VanshikaSabharwal commented Nov 17, 2024

What kind of change does this PR introduce?

feature

Issue Number:

Fixes #2446

Did you add tests for your changes?

No

Snapshots/Videos:

talawa-docker-setup-v1.mp4

If relevant, did you update the documentation?

Summary

Does this PR introduce a breaking change?

Other information

Have you read the contributing guide?

Yes

Summary by CodeRabbit

  • New Features

    • Enhanced installation instructions for talawa-admin, including detailed Docker commands and setup steps.
    • Introduced a new function askForDocker to prompt users for Docker configuration.
    • Added new dependencies for Dockerfile and markdown linting.
  • Bug Fixes

    • Improved error handling and feedback during the setup process.
  • Documentation

    • Updated INSTALLATION.md for clarity and detail.
    • Revised .eslintignore to exclude additional files from linting.
    • Added new guidelines and clarifications to CONTRIBUTING.md regarding test coverage and pull request submissions.
    • Improved formatting and clarity in DOCUMENTATION.md and ISSUE_GUIDELINES.md.
    • Enhanced the README.md for community engagement and list presentation.
  • Tests

    • Added a test suite for the askForDocker function to validate port handling.
  • Refactor

    • Streamlined the AddOn component to enhance type safety and clarity.
    • Updated workflow configuration to remove unnecessary jobs and improve file checks.
    • Enhanced the setup process for managing environment variables and user interactions.
    • Improved the check-localstorage-usage.js script to clarify file skipping logic.
    • Adjusted ESLint configuration to broaden ignore patterns and refine linting rules.
    • Updated Dockerfile to use a lighter base image and modified exposed port.

VanshikaSabharwal and others added 30 commits November 8, 2024 15:26
Bumps [sass](https://github.com/sass/dart-sass) from 1.80.6 to 1.80.7.
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/main/CHANGELOG.md)
- [Commits](sass/dart-sass@1.80.6...1.80.7)

---
updated-dependencies:
- dependency-name: sass
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…oesFoundation#2434)

Bumps [eslint-plugin-import](https://github.com/import-js/eslint-plugin-import) from 2.30.0 to 2.31.0.
- [Release notes](https://github.com/import-js/eslint-plugin-import/releases)
- [Changelog](https://github.com/import-js/eslint-plugin-import/blob/main/CHANGELOG.md)
- [Commits](import-js/eslint-plugin-import@v2.30.0...v2.31.0)

---
updated-dependencies:
- dependency-name: eslint-plugin-import
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…dation#2435)

Bumps [@mui/x-charts](https://github.com/mui/mui-x/tree/HEAD/packages/x-charts) from 7.22.1 to 7.22.2.
- [Release notes](https://github.com/mui/mui-x/releases)
- [Changelog](https://github.com/mui/mui-x/blob/v7.22.2/CHANGELOG.md)
- [Commits](https://github.com/mui/mui-x/commits/v7.22.2/packages/x-charts)

---
updated-dependencies:
- dependency-name: "@mui/x-charts"
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…dation#2436)

Bumps [@types/react](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/react) from 18.3.3 to 18.3.12.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/react)

---
updated-dependencies:
- dependency-name: "@types/react"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Copy link

coderabbitai bot commented Dec 3, 2024

@palisadoes: I will review the changes.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@palisadoes
Copy link
Contributor

@coderabbitai full review

Copy link

coderabbitai bot commented Dec 3, 2024

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (6)
setup.ts (2)

Line range hint 27-37: Add error handling to 'handleEnvFile' function

To ensure robustness, consider adding error handling for file operations in handleEnvFile to handle potential exceptions during file creation and validation.

Apply this diff to add error handling:

 const handleEnvFile = (): void => {
+  try {
     if (!fs.existsSync('.env')) {
       fs.openSync('.env', 'w');
       const config = dotenv.parse(fs.readFileSync('.env.example'));
       for (const key in config) {
         fs.appendFileSync('.env', `${key}=${config[key]}\n`);
       }
     } else {
       checkEnvFile();
     }
+  } catch (error) {
+    throw new Error(`Failed to handle .env file: ${error.message}`);
+  }
 };

90-124: Enhance error messages and URL validation in 'askAndUpdateTalawaApiUrl'

To improve user feedback, consider providing more descriptive error messages and enhancing URL validation to catch additional edge cases.

Apply this diff to enhance error handling:

 if (!['http:', 'https:'].includes(url.protocol)) {
-  throw new Error('Invalid URL protocol. Must be http or https');
+  throw new Error(`Invalid URL protocol '${url.protocol}'. Must be 'http:' or 'https:'`);
 }
 isConnected = await checkConnection(url.origin);

 updateEnvFile('REACT_APP_TALAWA_URL', endpoint);
 const websocketUrl = endpoint.replace(/^http(s)?:\/\//, 'ws$1://');
 try {
   new URL(websocketUrl);
 } catch (error) {
-  throw new Error('Invalid WebSocket URL generated');
+  throw new Error(`Invalid WebSocket URL generated from '${endpoint}': ${error.message}`);
 }
 updateEnvFile('REACT_APP_BACKEND_WEBSOCKET_URL', websocketUrl);
 if (endpoint.includes('localhost')) {
   const dockerUrl = endpoint.replace('localhost', 'host.docker.internal');
   updateEnvFile('REACT_APP_DOCKER_TALAWA_URL', dockerUrl);
 }
Dockerfile (1)

Line range hint 1-15: Synchronize exposed port with environment configuration

The Dockerfile currently exposes port 4321, which may not match the custom port specified during setup. To ensure consistency, consider parameterizing the exposed port or updating it to match the DOCKER_PORT.

Consider using an environment variable for the port:

 FROM node:20.10.0-alpine AS build

 WORKDIR /usr/src/app

 COPY package*.json ./

 RUN npm install

 COPY . .

 RUN npm run build

-EXPOSE 4321
+ARG PORT=4321
+ENV PORT=$PORT
+EXPOSE $PORT

 CMD ["npm", "run", "serve"]

Then, in your setup.ts, ensure that the PORT argument is passed during the Docker build:

docker build -t ${DOCKER_NAME} --build-arg PORT=${DOCKER_PORT_NUMBER} .
.eslintignore (1)

15-17: Correct ignore patterns in '.eslintignore'

The ignore patterns on lines 15-17 may contain syntax errors and may not correctly ignore the intended files. Please adjust the patterns to ensure they function as expected.

Apply this diff to fix the patterns:

 **/*.yml
-**/_.dockerfile
-\*\*/_.py \*_/_.md
+**/*.dockerfile
+**/*.py
+**/*.md
.github/workflows/pull-request.yml (1)

Line range hint 219-246: Improve test coverage report handling

The coverage report merging logic has been improved, but error handling could be enhanced.

Consider adding more detailed error reporting:

if ! npx lcov-result-merger 'coverage/*/lcov.info' > 'coverage/lcov.info'; then
-  echo "Failed to merge coverage reports"
+  echo "Error: Failed to merge coverage reports from Jest and Vitest"
+  echo "Please check if both test suites generated valid coverage data"
  exit 1
fi
INSTALLATION.md (1)

158-183: Enhance Docker development setup documentation

Consider adding these important sections to improve the Docker setup experience:

  1. Add a Docker Compose configuration for development
  2. Include a troubleshooting section for common Docker issues
  3. Add development-specific Docker configurations (e.g., volume mounts for hot reloading)

Example Docker Compose configuration:

version: '3.8'
services:
  talawa-admin:
    build:
      context: .
      target: development
    ports:
      - "4321:4321"
    volumes:
      - .:/app
      - /app/node_modules
    environment:
      - NODE_ENV=development
    command: npm run serve

This would simplify the development setup and ensure consistency across environments.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c2630ae and ae3dac5.

📒 Files selected for processing (10)
  • .eslintignore (1 hunks)
  • .github/workflows/pull-request.yml (10 hunks)
  • Dockerfile (2 hunks)
  • INSTALLATION.md (1 hunks)
  • scripts/githooks/check-localstorage-usage.js (1 hunks)
  • scripts/githooks/update-toc.js (0 hunks)
  • setup.ts (3 hunks)
  • src/components/AddOn/AddOn.tsx (1 hunks)
  • src/setup/askForDocker/askForDocker.test.ts (1 hunks)
  • src/setup/askForDocker/askForDocker.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • scripts/githooks/update-toc.js
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml

62-62: shellcheck reported issue in this script: SC2086:info:7:14: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (10)
setup.ts (3)

195-198: Use 'error.message' for clearer error output

To improve readability of error messages, consider logging error.message instead of the entire error object.

Apply this diff to adjust the error logging:

 } catch (error) {
-  console.error('\n❌ Setup failed:', error);
+  console.error('\n❌ Setup failed:', error.message);
   console.log('\nPlease try again or contact support if the issue persists.');
   process.exit(1);
 }

12-24: 🛠️ Refactor suggestion

Add error handling to 'updateEnvFile' function

To enhance robustness, consider adding error handling for file operations in updateEnvFile to handle potential exceptions during file read/write operations.

Apply this diff to add error handling:

 const updateEnvFile = (key: string, value: string): void => {
+  try {
     const currentEnvContent = fs.readFileSync('.env', 'utf8');
     const keyRegex = new RegExp(`^${key}=.*$`, 'm');
     if (keyRegex.test(currentEnvContent)) {
       const updatedEnvContent = currentEnvContent.replace(
         keyRegex,
         `${key}=${value}`,
       );
       fs.writeFileSync('.env', updatedEnvContent, 'utf8');
     } else {
       fs.appendFileSync('.env', `\n${key}=${value}`, 'utf8');
     }
+  } catch (error) {
+    throw new Error(`Failed to update environment variable ${key}: ${error.message}`);
+  }
 };

40-57: 🛠️ Refactor suggestion

Check if the custom port is available

Currently, the function verifies if the custom port is within the valid range but does not check if the port is already in use. To prevent runtime errors, consider adding a check to verify if the port is available.

Apply this diff to add port availability check:

 if (shouldSetCustomPortResponse) {
   const customPort = await askForCustomPort();
   if (customPort < 1024 || customPort > 65535) {
     throw new Error('Port must be between 1024 and 65535');
   }

+  // Check if port is available
+  try {
+    const server = require('net').createServer();
+    await new Promise((resolve, reject) => {
+      server.once('error', err => {
+        if (err.code === 'EADDRINUSE') {
+          reject(new Error(`Port ${customPort} is already in use`));
+        } else {
+          reject(err);
+        }
+      });
+      server.once('listening', () => {
+        server.close();
+        resolve(true);
+      });
+      server.listen(customPort);
+    });
+  } catch (error) {
+    throw error;
+  }

   updateEnvFile('PORT', String(customPort));
 }
src/setup/askForDocker/askForDocker.ts (1)

5-10: ⚠️ Potential issue

Add validation for Docker port input

The askForDocker function currently lacks validation for the dockerAppPort input. To ensure proper configuration, consider adding validation to check that the port number is numeric and within the valid range (1024-65535).

Apply this diff to add input validation:

 {
   type: 'input',
   name: 'dockerAppPort',
   message: 'Enter the port to expose Docker (default: 4321):',
   default: 4321,
+  validate: (input: string): boolean | string => {
+    const port = parseInt(input, 10);
+    if (isNaN(port)) {
+      return 'Port must be a number';
+    }
+    if (port < 1024 || port > 65535) {
+      return 'Port must be between 1024 and 65535';
+    }
+    return true;
+  },
 },
src/components/AddOn/AddOn.tsx (1)

5-5: ⚠️ Potential issue

Type definition conflicts with PropTypes validation

The extras prop type is defined as string but validated in PropTypes as an object shape with components and actions. Additionally, this prop is not used in the component implementation despite being documented.

Consider one of these solutions:

  1. Remove the unused extras prop:
interface InterfaceAddOnProps {
-  extras?: string;
  name?: string;
  children?: React.ReactNode;
}
  1. Or implement the prop with correct typing:
interface InterfaceAddOnProps {
-  extras?: string;
+  extras?: {
+    components?: Record<string, unknown>;
+    actions?: Record<string, unknown>;
+  };
  name?: string;
  children?: React.ReactNode;
}

Likely invalid or redundant comment.

scripts/githooks/check-localstorage-usage.js (1)

89-92: LGTM! Improved error messages

The updated messages provide clearer guidance by specifically mentioning the custom hook functions and their available methods.

.github/workflows/pull-request.yml (2)

63-77: ⚠️ Potential issue

Fix shell script security vulnerabilities

The current implementation has potential security issues with unquoted variables and file pattern handling.

Apply this diff to fix the issues:

# Filter files to include only .ts and .tsx files
-TS_FILES=$(echo "$CHANGED_FILES" | grep -E '\.(ts|tsx)$')
+TS_FILES=$(echo "${CHANGED_FILES}" | grep -E '\.(ts|tsx)$' || true)

# Check if there are any TypeScript files to lint
-if [ -n "$TS_FILES" ]; then
+if [ -n "${TS_FILES}" ]; then
  # Run linting on the changed TypeScript files
-  npx eslint $TS_FILES --ignore-pattern '**/*.yml' --ignore-pattern '**/*.dockerfile' --ignore-pattern '**/*.py' --ignore-pattern '**/*.md' --no-ignore
+  npx eslint "${TS_FILES}" --ignore-pattern '{**/*.yml,**/*.dockerfile,**/*.py,**/*.md}' --no-ignore

Likely invalid or redundant comment.


285-297: ⚠️ Potential issue

Enhance API repository cloning reliability

The current implementation lacks proper error handling and variable quoting.

Apply this diff to improve reliability:

# Retrieve the complete branch name directly from the GitHub context
-FULL_BRANCH_NAME=${{ github.base_ref }}
-echo "FULL_Branch_NAME: $FULL_BRANCH_NAME"
+FULL_BRANCH_NAME="${{ github.base_ref }}"
+if [ -z "${FULL_BRANCH_NAME}" ]; then
+  echo "Error: Base branch name is empty"
+  exit 1
+fi
+echo "Full branch name: ${FULL_BRANCH_NAME}"

# Clone the specified repository using the extracted branch name
-git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a
+if ! git clone --branch "${FULL_BRANCH_NAME}" https://github.com/PalisadoesFoundation/talawa-api; then
+  echo "Error: Failed to clone repository"
+  exit 1
+fi

Likely invalid or redundant comment.

INSTALLATION.md (2)

158-174: Improve Docker run command documentation

The Docker run commands need more explanation and robustness:

  1. Add explanations for Docker flags
  2. Fix potential Windows path issues
  3. Address environment variable persistence

178-183: Expand container management instructions

The container management section needs more comprehensive instructions for proper container lifecycle management.

src/setup/askForDocker/askForDocker.test.ts Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
.eslintrc.json (1)

136-159: Consider consolidating ignore patterns for better maintainability

The ignore patterns can be simplified using more concise glob patterns:

   "ignorePatterns": [
-    "**/*.css",
-    "**/*.scss",
-    "**/*.less",
-    "**/*.json",
-    "**/*.md",
-    "**/*.js",
-    "**/*.test.js",
-    "**/*.test.ts",
-    "**/*.test.tsx",
-    "**/*.spec.js",
-    "**/*.spec.ts",
-    "**/*.spec.tsx",
-    "**/*.d.ts",
-    "**/*.config.js",
-    "**/*.config.ts",
-    "**/*.babel.js",
-    "**/*.eslint.js",
+    "**/*.{css,scss,less,json,md,js}",
+    "**/*.{test,spec}.{js,ts,tsx}",
+    "**/*.d.ts",
+    "**/*.{config,babel,eslint}.{js,ts}",
     "**/node_modules/**",
     "**/build/**",
     "**/dist/**",
     "**/coverage/**",
     "**/public/**"
   ]
.github/workflows/pull-request.yml (3)

Line range hint 154-157: Fix word splitting vulnerability in file iteration

The current implementation doesn't properly handle filenames containing spaces.

-          for file in ${CHANGED_UNAUTH_FILES}; do
+          while IFS= read -r file; do
             echo "$file is unauthorized to change/delete"
-          done
+          done <<< "${CHANGED_UNAUTH_FILES}"

Line range hint 248-254: Fix TypeScript compilation loop

The current implementation has potential issues with word splitting and file handling.

-          for file in ${{ steps.changed-files.outputs.all_files }}; do
+          while IFS= read -r file; do
             if [[ "$file" == *.ts || "$file" == *.tsx ]]; then
               npx tsc --noEmit "$file"
             fi
-          done
+          done <<< "${{ steps.changed-files.outputs.all_files }}"

Line range hint 219-246: Consider adding retry mechanism for coverage report merging

The coverage report merging could fail due to timing issues.

       - name: Merge Coverage Reports
         if: steps.changed-files.outputs.only_changed != 'true'
         run: |
           mkdir -p coverage
-          if ! npx lcov-result-merger 'coverage/*/lcov.info' > 'coverage/lcov.info'; then
-            echo "Failed to merge coverage reports"
-            exit 1
-          fi
+          max_attempts=3
+          attempt=1
+          while [ $attempt -le $max_attempts ]; do
+            if npx lcov-result-merger 'coverage/*/lcov.info' > 'coverage/lcov.info'; then
+              echo "Successfully merged coverage reports"
+              break
+            fi
+            echo "Attempt $attempt failed. Retrying in 5 seconds..."
+            sleep 5
+            attempt=$((attempt + 1))
+          done
+          if [ $attempt -gt $max_attempts ]; then
+            echo "Failed to merge coverage reports after $max_attempts attempts"
+            exit 1
+          fi
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ae3dac5 and e863c6b.

📒 Files selected for processing (3)
  • .eslintignore (1 hunks)
  • .eslintrc.json (1 hunks)
  • .github/workflows/pull-request.yml (10 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .eslintignore
🔇 Additional comments (2)
.github/workflows/pull-request.yml (2)

287-294: ⚠️ Potential issue

Improve branch handling and error checking

The current implementation lacks proper error handling for git operations.

         run: |
-          # Retrieve the complete branch name directly from the GitHub context
-          FULL_BRANCH_NAME=${{ github.base_ref }}
-          echo "FULL_Branch_NAME: $FULL_BRANCH_NAME"
+          # Safely handle branch names
+          FULL_BRANCH_NAME="${{ github.base_ref }}"
+          if [ -z "${FULL_BRANCH_NAME}" ]; then
+            echo "Error: Base branch name is empty"
+            exit 1
+          fi
+          echo "Full branch name: ${FULL_BRANCH_NAME}"

-          # Clone the specified repository using the extracted branch name
-          git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a
+          # Clone the repository with proper error handling
+          if ! git clone --branch "${FULL_BRANCH_NAME}" https://github.com/PalisadoesFoundation/talawa-api; then
+            echo "Error: Failed to clone repository"
+            exit 1
+          fi

Likely invalid or redundant comment.


63-77: ⚠️ Potential issue

Fix shell script security vulnerabilities

The current implementation has potential security issues with unquoted variables.

-          TS_FILES=$(echo "$CHANGED_FILES" | grep -E '\.(ts|tsx)$')
+          TS_FILES=$(echo "${CHANGED_FILES}" | grep -E '\.(ts|tsx)$' || true)

-          if [ -n "$TS_FILES" ]; then
+          if [ -n "${TS_FILES}" ]; then
             # Run linting on the changed TypeScript files
             npx eslint "${TS_FILES}" --ext .ts,.tsx --ignore-pattern '{**/*.yml,**/*.dockerfile,**/*.py,**/*.md}'

Likely invalid or redundant comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
.github/workflows/pull-request.yml (2)

Line range hint 151-157: Fix word splitting vulnerability in unauthorized files check

The current implementation doesn't properly handle filenames containing spaces.

Apply this diff:

        env:
          CHANGED_UNAUTH_FILES: ${{ steps.changed-unauth-files.outputs.all_changed_files }}
        run: |
-          for file in ${CHANGED_UNAUTH_FILES}; do
+          while IFS= read -r file; do
             echo "$file is unauthorized to change/delete"
-          done
+          done <<< "${CHANGED_UNAUTH_FILES}"
           exit 1

Line range hint 248-253: Improve TypeScript compilation robustness

The current implementation needs better error handling and variable quoting.

Apply this diff:

       - name: TypeScript compilation for changed files
         run: |
-          for file in ${{ steps.changed-files.outputs.all_files }}; do
+          failed=0
+          while IFS= read -r file; do
             if [[ "$file" == *.ts || "$file" == *.tsx ]]; then
-              npx tsc --noEmit "$file"
+              if ! npx tsc --noEmit "$file"; then
+                failed=1
+              fi
             fi
-          done
+          done <<< "${{ steps.changed-files.outputs.all_files }}"
+          exit $failed
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e863c6b and a859d25.

📒 Files selected for processing (1)
  • .github/workflows/pull-request.yml (10 hunks)
🔇 Additional comments (3)
.github/workflows/pull-request.yml (3)

172-182: LGTM: Proper environment variable handling

The implementation correctly handles the file count check with proper environment variable usage.


285-297: ⚠️ Potential issue

Improve branch handling and error checking

The current implementation needs better error handling and variable safety.

Apply this diff:

       - name: Clone API Repository
         run: |
-          # Retrieve the complete branch name directly from the GitHub context
-          FULL_BRANCH_NAME=${{ github.base_ref }}
-          echo "FULL_Branch_NAME: $FULL_BRANCH_NAME"
+          # Safely handle branch names
+          FULL_BRANCH_NAME="${{ github.base_ref }}"
+          if [ -z "${FULL_BRANCH_NAME}" ]; then
+            echo "Error: Base branch name is empty"
+            exit 1
+          fi
+          echo "Full branch name: ${FULL_BRANCH_NAME}"

-          # Clone the specified repository using the extracted branch name
-          git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a
+          # Clone the repository with proper error handling
+          if ! git clone --branch "${FULL_BRANCH_NAME}" https://github.com/PalisadoesFoundation/talawa-api; then
+            echo "Error: Failed to clone repository"
+            exit 1
+          fi

       - name: Validate Documents
-        run: graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql'
+        run: |
+          if [ ! -f './talawa-api/schema.graphql' ]; then
+            echo "Error: schema.graphql not found"
+            exit 1
+          fi
+          graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql'

Likely invalid or redundant comment.


60-78: 🛠️ Refactor suggestion

Improve shell script robustness and maintainability

The linting implementation can be enhanced:

  1. Quote variables to prevent word splitting
  2. Use a separate file for ignore patterns
  3. Remove unnecessary empty lines

Apply this diff:

        env:
          CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
        run: |
          # Filter files to include only .ts and .tsx files
-          TS_FILES=$(echo "$CHANGED_FILES" | grep -E '\.(ts|tsx)$')
+          TS_FILES=$(echo "${CHANGED_FILES}" | grep -E '\.(ts|tsx)$' || true)

          # Check if there are any TypeScript files to lint
-          if [ -n "$TS_FILES" ]; then
+          if [ -n "${TS_FILES}" ]; then
             # Run linting on the changed TypeScript files
             npx eslint "${TS_FILES}" --ignore-pattern '{**/*.yml,**/*.dockerfile,**/*.py,**/*.md}'

-
-
-
             # Run the Python script for eslint-disable check on the TypeScript files
             python .github/workflows/eslint_disable_check.py
           else
             echo "No .ts or .tsx files to lint."
           fi

Likely invalid or redundant comment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
.eslintrc.json (1)

69-69: Consider keeping explicit return types for better type safety

Disabling @typescript-eslint/explicit-function-return-type might reduce code clarity and type safety. While TypeScript can infer return types, explicit types help with:

  • Documentation
  • Catching errors early
  • Making refactoring easier

Consider keeping this rule enabled with allowances for expressions:

-    "@typescript-eslint/explicit-function-return-type": "off",
+    "@typescript-eslint/explicit-function-return-type": ["error", {
+      "allowExpressions": true,
+      "allowTypedFunctionExpressions": true
+    }],
.github/workflows/pull-request.yml (1)

Line range hint 204-231: Improve test coverage reporting robustness

The coverage merging implementation could be more robust.

Consider adding more error handling:

      - name: Merge Coverage Reports
        if: steps.changed-files.outputs.only_changed != 'true'
        run: |
          mkdir -p coverage
+          # Check if coverage directories exist
+          if [ ! -d "coverage/jest" ] && [ ! -d "coverage/vitest" ]; then
+            echo "No coverage directories found"
+            exit 1
+          fi
+          
+          # Check if lcov files exist
+          if [ ! -f "coverage/jest/lcov.info" ] && [ ! -f "coverage/vitest/lcov.info" ]; then
+            echo "No lcov.info files found"
+            exit 1
+          fi
+          
           if ! npx lcov-result-merger 'coverage/*/lcov.info' > 'coverage/lcov.info'; then
             echo "Failed to merge coverage reports"
             exit 1
           fi
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a859d25 and 3591428.

📒 Files selected for processing (4)
  • .eslintignore (1 hunks)
  • .eslintrc.json (1 hunks)
  • .github/workflows/pull-request.yml (9 hunks)
  • jest.config.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • jest.config.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • .eslintignore
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/pull-request.yml

62-62: shellcheck reported issue in this script: SC2086:info:1:12: Double quote to prevent globbing and word splitting

(shellcheck)

🔇 Additional comments (2)
.github/workflows/pull-request.yml (2)

Line range hint 133-142: Fix word splitting vulnerability in unauthorized files check

The current implementation doesn't properly handle filenames containing spaces.


270-280: ⚠️ Potential issue

Improve branch handling in API repository clone

The current implementation lacks proper error handling and variable quoting.

Apply this fix:

      - name: Clone API Repository
        run: |
-          # Retrieve the complete branch name directly from the GitHub context
-          FULL_BRANCH_NAME=${{ github.base_ref }}
-          echo "FULL_Branch_NAME: $FULL_BRANCH_NAME"
-
-          # Clone the specified repository using the extracted branch name
-          git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a
+          # Safely handle branch names
+          FULL_BRANCH_NAME="${{ github.base_ref }}"
+          if [ -z "${FULL_BRANCH_NAME}" ]; then
+            echo "Error: Base branch name is empty"
+            exit 1
+          fi
+          echo "Full branch name: ${FULL_BRANCH_NAME}"
+          
+          # Clone with proper error handling
+          if ! git clone --branch "${FULL_BRANCH_NAME}" https://github.com/PalisadoesFoundation/talawa-api; then
+            echo "Error: Failed to clone repository"
+            exit 1
+          fi

Likely invalid or redundant comment.

.github/workflows/pull-request.yml Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (10)
ISSUE_GUIDELINES.md (1)

55-62: Fix capitalization and punctuation

Proper noun capitalization and list punctuation need correction.

Apply these corrections:

-1. Join our `#talawa-github` slack channel for automatic issue and pull request updates.
+1. Join our `#talawa-github` Slack channel for automatic issue and pull request updates.

-1. Discuss issues in our various slack channels when necessary
+1. Discuss issues in our various Slack channels when necessary,
🧰 Tools
🪛 LanguageTool

[grammar] ~57-~57: Did you mean the communication tool “Slack” (= proper noun, capitalized)?
Context: ...ew Issues 1. Join our #talawa-github slack channel for automatic issue and pull re...

(ON_SKYPE)


[grammar] ~61-~61: Did you mean the communication tool “Slack” (= proper noun, capitalized)?
Context: ...lines 1. Discuss issues in our various slack channels when necessary 2. Please do no...

(ON_SKYPE)


[typographical] ~61-~61: Consider adding a comma here.
Context: ...ur various slack channels when necessary 2. Please do not derail or troll issues. 3. Keep ...

(PLEASE_COMMA)

package.json (1)

Version mismatch detected between React and its type definitions

The project is using React v18.3.1 but has pinned @types/react to v17.0.2, which could lead to type checking issues. The current setup shows:

  • React: ^18.3.1
  • @types/react: 17.0.2 (pinned)
  • @types/react-dom: 17.0.2 (pinned)

You should update the type definitions to match the React version:

  • Update @types/react to ^18.3.12
  • Update @types/react-dom to ^18.3.1

Other dependencies look compatible:

  • graphql ^16.5.0 is compatible (latest is 16.9.0)
  • @apollo/client ^3.4.0-beta.19 should be updated to a stable version (current stable is 3.11.10)
🔗 Analysis chain

Line range hint 165-170: Verify compatibility of pinned dependency versions

Please ensure these specific versions are compatible with the project's requirements.


Let me gather more information about the React version being used in the project to ensure compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential compatibility issues with pinned versions

# Check if these versions are the latest stable ones
echo "Checking latest versions from npm registry..."
for pkg in "@apollo/client" "@types/react" "@types/react-dom" "graphql"; do
  echo "Latest version for $pkg:"
  curl -s "https://registry.npmjs.org/$pkg" | jq -r '.["dist-tags"].latest'
done

Length of output: 1057


Script:

#!/bin/bash
# Check React version in package.json
echo "Checking React version..."
rg '"react":' package.json

# Check for React usage patterns that might indicate version requirements
echo -e "\nChecking React usage patterns..."
ast-grep --pattern 'import { $$ } from "react"'

Length of output: 244

talawa-admin-docs/modules/screens_Users_UsersMocks.md (1)

27-27: Consider refactoring duplicate mock structures

MOCKS and MOCKS2 contain identical structures and data. Consider refactoring to reduce duplication and improve maintainability.

+ // Create a base mock structure
+ const BASE_USER_MOCK = {
+   _id: 'user1',
+   email: '<john@example.com>',
+   firstName: 'John',
+   lastName: 'Doe'
+ };

+ // Use the base structure in both MOCKS and MOCKS2
+ const MOCKS = [...generateMocks(BASE_USER_MOCK)];
+ const MOCKS2 = [...generateMocks(BASE_USER_MOCK)];

Also applies to: 37-37

CODE_STYLE.md (3)

57-64: Add language identifier to code block

Specify the language for the code block to enable proper syntax highlighting.

-```
+```jsx
 <div className="myCustomClass">...</div>
 <div className={`${styles.myCustomClass1} myCustomClass2`}>...</div>
 .container{...}
🧰 Tools
🪛 Markdownlint (0.35.0)

64-64: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


58-58: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


78-79: Improve text conciseness

Consider condensing the explanation while maintaining its clarity.

-Using plain Bootstrap classes and attributes without leveraging the React-Bootstrap library should be refrained. While it may work for basic functionality, it doesn't fully integrate with React and may cause issues when dealing with more complex state management or component interactions.
+Using plain Bootstrap classes without React-Bootstrap is discouraged as it may cause issues with React's state management and component interactions.

130-139: Remove redundant phrases

The repeated use of "All of the" makes the text unnecessarily verbose.

-- `css` - This houses all of the css files used in the project
-- `images` - This houses all of the images used in the project
-- `scss` - This houses all of the scss files used in the project
+- `css` - Contains CSS files used in the project
+- `images` - Contains images used in the project
+- `scss` - Contains SCSS files used in the project
🧰 Tools
🪛 LanguageTool

[style] ~130-~130: Consider removing “of” to be more concise
Context: ...d in the project - css - This houses all of the css files used in the project - `images...

(ALL_OF_THE)


[style] ~131-~131: Consider removing “of” to be more concise
Context: ...in the project - images - This houses all of the images used in the project - scss - T...

(ALL_OF_THE)


[style] ~132-~132: Consider removing “of” to be more concise
Context: ...d in the project - scss - This houses all of the scss files used in the project - `com...

(ALL_OF_THE)


[grammar] ~136-~136: The singular proper name ‘Sass’ must be used with a third-person or a past tense verb.
Context: ...forms - _talawa.scss - Partial Sass file for Talawa - _utilities.scss - Part...

(HE_VERB_AGR)


[grammar] ~137-~137: The singular proper name ‘Sass’ must be used with a third-person or a past tense verb.
Context: ...wa - _utilities.scss - Partial Sass file for utilities - _variables.scss - P...

(HE_VERB_AGR)


[grammar] ~138-~138: The singular proper name ‘Sass’ must be used with a third-person or a past tense verb.
Context: ...es - _variables.scss - Partial Sass file for variables - app.scss - Main Sas...

(HE_VERB_AGR)

CONTRIBUTING.md (1)

128-151: Add language identifiers to code blocks

Code blocks should specify their language for proper syntax highlighting.

-```
+```bash
 npm install
 npm run test --watchAll=false --coverage
 genhtml coverage/lcov.info -o coverage

- +bash
npm run test --watchAll=false /path/to/test/file


-```
+```bash
 npm run test --watchAll=false --coverage /path/to/test/file
🧰 Tools
🪛 LanguageTool

[grammar] ~137-~137: The operating system from Apple is written “macOS”.
Context: ...r packages can be found for Windows and MacOS. 6. The currently acceptable c...

(MAC_OS)

🪛 Markdownlint (0.35.0)

129-129: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


142-142: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


148-148: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

.dockerfilelintrc.json (1)

1-5: LGTM! Consider adding documentation.

The linting configuration is well-structured with appropriate strict settings that will help maintain Docker best practices. However, it would be helpful to add a comment block explaining the purpose of each setting.

Consider adding a comment block at the top of the file:

 {
+  // Configuration for dockerfilelint
+  // skipShellCheck: When false, enables validation of shell commands in Dockerfiles
+  // skipCritical: When false, enables critical security and best practice checks
+  // disableLineBreaks: When false, enforces proper line break formatting
   "skipShellCheck": false,
   "skipCritical": false,
   "disableLineBreaks": false
 }
🧰 Tools
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch

[warning] 1-1:
File ignored by default.

DOCUMENTATION.md (2)

31-31: Fix typo in browser word.

There's a typo in the word "browser".

Apply this correction:

-1. Always monitor the local website in your brower to make sure the changes are acceptable.
+1. Always monitor the local website in your browser to make sure the changes are acceptable.

Line range hint 35-37: Capitalize "Markdown" as a proper noun.

For consistency and correctness, "Markdown" should be capitalized when referring to the formatting language.

Apply this correction:

-***PLEASE*** do not add markdown files in this repository. Add them to `talawa-docs`!
+***PLEASE*** do not add Markdown files in this repository. Add them to `talawa-docs`!
🧰 Tools
🪛 LanguageTool

[grammar] ~28-~28: The modal verb ‘should’ requires the verb’s base form.
Context: ...f docs.talawa.io should automatically launched in your browser at <http://localhost:30...

(MD_BASEFORM)


[grammar] ~29-~29: Did you mean the formatting language “Markdown” (= proper noun)?
Context: ...tp://localhost:3000/> 1. Add/modify the markdown documents to the docs/ directory of t...

(MARKDOWN_NNP)


[uncategorized] ~36-~36: The preposition “to” seems more likely in this position.
Context: ... PLEASE do not add markdown files in this repository. Add them to `talawa-do...

(AI_EN_LECTOR_REPLACEMENT_PREPOSITION)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between c860961 and 5be01a6.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (13)
  • .dockerfilelintrc.json (1 hunks)
  • CODE_STYLE.md (7 hunks)
  • CONTRIBUTING.md (1 hunks)
  • DOCUMENTATION.md (2 hunks)
  • INSTALLATION.md (7 hunks)
  • ISSUE_GUIDELINES.md (3 hunks)
  • PR_GUIDELINES.md (1 hunks)
  • README.md (2 hunks)
  • package.json (2 hunks)
  • talawa-admin-docs/README.md (2 hunks)
  • talawa-admin-docs/modules/components_OrgUpdate_OrgUpdateMocks.md (2 hunks)
  • talawa-admin-docs/modules/screens_OrganizationDashboard_OrganizationDashboardMocks.md (2 hunks)
  • talawa-admin-docs/modules/screens_Users_UsersMocks.md (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • talawa-admin-docs/README.md
  • README.md
🧰 Additional context used
🪛 LanguageTool
ISSUE_GUIDELINES.md

[typographical] ~26-~26: Consider adding a comma here.
Context: ... ___ ## Issue Management In all cases please use the [GitHub open issue search](http...

(PLEASE_COMMA)


[grammar] ~57-~57: Did you mean the communication tool “Slack” (= proper noun, capitalized)?
Context: ...ew Issues 1. Join our #talawa-github slack channel for automatic issue and pull re...

(ON_SKYPE)


[grammar] ~61-~61: Did you mean the communication tool “Slack” (= proper noun, capitalized)?
Context: ...lines 1. Discuss issues in our various slack channels when necessary 2. Please do no...

(ON_SKYPE)


[typographical] ~61-~61: Consider adding a comma here.
Context: ...ur various slack channels when necessary 2. Please do not derail or troll issues. 3. Keep ...

(PLEASE_COMMA)

CONTRIBUTING.md

[grammar] ~137-~137: The operating system from Apple is written “macOS”.
Context: ...r packages can be found for Windows and MacOS. 6. The currently acceptable c...

(MAC_OS)

CODE_STYLE.md

[style] ~128-~128: Consider removing “of” to be more concise
Context: ...tories of src assets - This houses all of the static assets used in the project - `c...

(ALL_OF_THE)


[style] ~130-~130: Consider removing “of” to be more concise
Context: ...d in the project - css - This houses all of the css files used in the project - `images...

(ALL_OF_THE)


[style] ~131-~131: Consider removing “of” to be more concise
Context: ...in the project - images - This houses all of the images used in the project - scss - T...

(ALL_OF_THE)


[style] ~132-~132: Consider removing “of” to be more concise
Context: ...d in the project - scss - This houses all of the scss files used in the project - `com...

(ALL_OF_THE)


[grammar] ~136-~136: The singular proper name ‘Sass’ must be used with a third-person or a past tense verb.
Context: ...forms - _talawa.scss - Partial Sass file for Talawa - _utilities.scss - Part...

(HE_VERB_AGR)


[grammar] ~137-~137: The singular proper name ‘Sass’ must be used with a third-person or a past tense verb.
Context: ...wa - _utilities.scss - Partial Sass file for utilities - _variables.scss - P...

(HE_VERB_AGR)


[grammar] ~138-~138: The singular proper name ‘Sass’ must be used with a third-person or a past tense verb.
Context: ...es - _variables.scss - Partial Sass file for variables - app.scss - Main Sas...

(HE_VERB_AGR)


[uncategorized] ~166-~166: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...the following order: - React imports - Third party imports - Local imports If there is mo...

(EN_COMPOUND_ADJECTIVE_INTERNAL)

DOCUMENTATION.md

[grammar] ~28-~28: The modal verb ‘should’ requires the verb’s base form.
Context: ...f docs.talawa.io should automatically launched in your browser at <http://localhost:30...

(MD_BASEFORM)


[grammar] ~29-~29: Did you mean the formatting language “Markdown” (= proper noun)?
Context: ...tp://localhost:3000/> 1. Add/modify the markdown documents to the docs/ directory of t...

(MARKDOWN_NNP)

🪛 Markdownlint (0.35.0)
CONTRIBUTING.md

129-129: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


142-142: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


148-148: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

CODE_STYLE.md

64-64: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


58-58: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

INSTALLATION.md

232-232: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


240-240: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


324-324: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
.dockerfilelintrc.json

[warning] 1-1:
File ignored by default.

🔇 Additional comments (9)
ISSUE_GUIDELINES.md (1)

Line range hint 8-23: LGTM! Well-structured Table of Contents

The addition of an automated Table of Contents improves document navigation and follows markdown best practices.

🧰 Tools
🪛 LanguageTool

[misspelling] ~5-~5: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...der to give everyone a chance to submit a issues reports and contribute to the Ta...

(EN_A_VS_AN)

PR_GUIDELINES.md (1)

Line range hint 50-71: LGTM! Comprehensive PR guidelines

The new guidelines effectively address key aspects:

  • Single PR at a time policy improves review quality
  • Clear stance on draft PRs and reviewer assignments
  • Specific requirements for PR size and conflict resolution
  • Clear timeline expectations for contributor responses

These additions will help maintain code quality and streamline the review process.

package.json (1)

141-141: LGTM! Appropriate new dev dependencies

The addition of dockerfilelint and markdownlint-cli supports:

  • Docker configuration validation
  • Markdown documentation quality

Also applies to: 156-156

talawa-admin-docs/modules/components_OrgUpdate_OrgUpdateMocks.md (1)

17-17: Standardize email format across mock data

The email formatting changes to include angle brackets (e.g., <johndoe@gmail.com>) align with email address format standardization across the codebase.

talawa-admin-docs/modules/screens_OrganizationDashboard_OrganizationDashboardMocks.md (2)

17-17: LGTM: Email format standardization

The email formatting changes in EMPTY_MOCKS align with the project-wide standardization effort.


37-37: Verify empty creator fields

The creator object contains empty strings for email, firstName, and lastName. This might cause issues if these fields are required in the application logic.

INSTALLATION.md (2)

160-176: Previous review comment is still applicable

The Docker run commands need more explanation and Windows path handling improvements as noted in the previous review.


180-185: Previous review comment is still applicable

The container management section needs more comprehensive instructions as noted in the previous review.

DOCUMENTATION.md (1)

2-2: LGTM! Documentation structure improvements.

The added welcome message and reformatted documentation locations improve readability and user experience.

Also applies to: 19-20

ISSUE_GUIDELINES.md Show resolved Hide resolved
DOCUMENTATION.md Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 4, 2024
@VanshikaSabharwal
Copy link
Author

Hello @palisadoes . I tried but this linting test is continously failing i tried to use ignore to ignore non .ts and tsx file. So, that non relevent files like Dockerfile, .yaml and other alike files do not get checked by eslint as it would cause error but it was not working.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 4, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
.github/workflows/pull-request.yml (2)

157-164: Improve error message for changed files count.

The error message could be more helpful by including the actual count.

Apply this diff to improve the error message:

         run: |
-          echo "Error: Too many files (greater than 100) changed in the pull request."
+          echo "Error: Too many files changed in the pull request (${CHANGED_FILES_COUNT} > 100)."
           echo "Possible issues:"

230-231: Improve error handling in coverage report merging.

Good error handling for the coverage merge, but could be more informative.

Apply this diff to improve error reporting:

         run: |
           mkdir -p coverage
           if ! npx lcov-result-merger 'coverage/*/lcov.info' > 'coverage/lcov.info'; then
-            echo "Failed to merge coverage reports"
+            echo "Failed to merge coverage reports from coverage/*/lcov.info"
+            echo "Please ensure all test runs generated coverage reports"
             exit 1
           fi
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 557c203 and 780ae27.

📒 Files selected for processing (1)
  • .github/workflows/pull-request.yml (9 hunks)
🔇 Additional comments (4)
.github/workflows/pull-request.yml (4)

49-49: LGTM: Formatting check with fallback.

The addition of a formatting check with a fallback to run formatting if the check fails is a good practice.


204-204: LGTM: Test setup with changed files detection.

The implementation correctly sets up the test environment and detects changed files.

Also applies to: 208-208


133-136: ⚠️ Potential issue

Fix word splitting vulnerability in unauthorized files check.

The current implementation is vulnerable to word splitting when handling filenames with spaces.


60-63: ⚠️ Potential issue

Fix potential shell script injection vulnerability.

The current implementation doesn't properly handle filenames with spaces and special characters.

Apply this diff to fix the security issue:

-        run: npx eslint "**/*.{js,jsx,ts,tsx}" --ignore-path .eslintignore
+        run: |
+          if [ -n "${CHANGED_FILES}" ]; then
+            # Use arrays to properly handle filenames with spaces
+            mapfile -t files < <(echo "${CHANGED_FILES}" | tr ' ' '\n' | grep -E '\.(js|jsx|ts|tsx)$' || true)
+            if [ ${#files[@]} -gt 0 ]; then
+              npx eslint "${files[@]}" --ignore-path .eslintignore
+            else
+              echo "No JavaScript/TypeScript files to lint"
+            fi
+          fi

Likely invalid or redundant comment.

.github/workflows/pull-request.yml Show resolved Hide resolved
Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I'm going to have to close this PR.
  2. You have submitted too many files that are out of scope of the original issue. It's going to be hard to review.
  3. The changes to the linting and testing configuration files and GitHub workflows are unnecessary and impact the overall quality of our code base

Please try again with a PR where these files not relevant to the issue excluded

@@ -57,10 +57,10 @@ jobs:

- name: Check for linting errors in modified files
if: steps.changed-files.outputs.only_changed != 'true'
env:
env:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

@@ -66,13 +66,7 @@
"@typescript-eslint/array-type": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": [
2,
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

@@ -1,5 +1,3 @@
# Contains the PDF file of the Tag as JSON string, thus does not need to be linted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

{
"skipShellCheck": false,
"skipCritical": false,
"disableLineBreaks": false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

@@ -1,4 +1,5 @@
# Documentation

Welcome to our documentation guide. Here are some useful tips you need to know!

# Table of Contents
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

@@ -125,24 +125,30 @@ The process of proposing a change to Talawa Admin can be summarized as:
1. _General Information_
1. The current code coverage of the repo is: [![codecov](https://codecov.io/gh/PalisadoesFoundation/talawa-admin/branch/develop/graph/badge.svg?token=II0R0RREES)](https://codecov.io/gh/PalisadoesFoundation/talawa-admin)
2. You can determine the percentage test coverage of your code by running these two commands in sequence:

```
npm install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

```bash
$ git clone https://github.com/{{YOUR GITHUB USERNAME}}/talawa-admin.git
cd talawa-admin
git checkout develop
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

@@ -19,14 +20,16 @@ ___
<!-- tocstop -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

@@ -47,6 +47,7 @@ npm run format:check
1. Please read our [CONTRIBUTING.md](CONTRIBUTING.md) document for details on our testing policy.

## Pull Request Processing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please revert all changes to this file.
  2. It is out of scope of the issue.
  3. The changes impede our ability to have the code quality we require as a project

README.md Show resolved Hide resolved
@palisadoes
Copy link
Contributor

  1. I'm going to have to close this PR.
  2. You have submitted too many files that are out of scope of the original issue. It's going to be hard to review.
  3. The changes to the linting and testing configuration files and GitHub workflows are unnecessary and impact the overall quality of our code base

Please try again with a PR where these files not relevant to the issue excluded

@palisadoes palisadoes closed this Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ignore-sensitive-files-pr The contributor has a legitimate reason for editiing protected files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants