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

feat: Added Camelcase Linters, complexity and max-params and code changes accordingly #137

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

himanshu-wedensday
Copy link

@himanshu-wedensday himanshu-wedensday commented May 8, 2024

###Description
In this Pr I have added following linters

<title>Table</title> <style> table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid black; padding: 8px; text-align: left; } th { background-color: #f2f2f2; } </style>
Linter Name Is Code Change Required
Complexity No
Max Param No
CamelCase Yes
### Ticket Link

Related Links


Description


Steps to Reproduce / Test



Checklist

  • PR description included
  • yarn test passes
  • Tests are [changed or added]
  • Relevant documentation is changed or added (and PR referenced)

GIF's


Summary by CodeRabbit

  • New Features

    • Updated the sqlite3 package to enhance database interactions and stability.
  • Refactor

    • Enforced stricter code quality rules by updating ESLint configurations, improving code readability and maintainability.
  • Style

    • Applied consistent code styling by disabling camelcase rules where necessary across various seeding files.

Copy link

coderabbitai bot commented May 8, 2024

Walkthrough

This update introduces stricter coding standards in the project by enforcing new ESLint rules for complexity, maximum parameters, and camelcase usage across various JavaScript files. It also updates the sqlite3 package version, and adapts the codebase to consistently use camelCase in key identifiers. ESLint exceptions are added in several seeders and other JavaScript files to accommodate existing naming conventions.

Changes

Files Change Summary
.eslintrc.js Added rules for max-params, complexity, and stricter camelcase.
package.json Updated sqlite3 from 5.0.2 to 5.1.7.
seeders/02_addresses.js to seeders/08_users.js Added eslint-disable camelcase directive.
server/database/index.js, server/database/tests/index.test.js Updated key from db_uri to dbUri.
server/gql/models/addresses/index.js, server/utils/testUtils/mockData.js Added eslint-disable camelcase and updated imports.

🐰✨
A hop, a skip, a code deploy,
New rules in the land, oh boy!
CamelCase reigns, complexity contained,
CodeRabbit's joy, in verses framed.
🌟📜🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ef85f3a and bf773c6.
Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/*.lock
Files selected for processing (13)
  • .eslintrc.js (2 hunks)
  • package.json (1 hunks)
  • seeders/02_addresses.js (1 hunks)
  • seeders/03_stores.js (1 hunks)
  • seeders/04_supplier.js (1 hunks)
  • seeders/05_supplier_products.js (1 hunks)
  • seeders/06_store_products.js (1 hunks)
  • seeders/07_purchased_products.js (1 hunks)
  • seeders/08_users.js (1 hunks)
  • server/database/index.js (1 hunks)
  • server/database/tests/index.test.js (1 hunks)
  • server/gql/models/addresses/index.js (1 hunks)
  • server/utils/testUtils/mockData.js (1 hunks)
Files skipped from review due to trivial changes (12)
  • package.json
  • seeders/02_addresses.js
  • seeders/03_stores.js
  • seeders/04_supplier.js
  • seeders/05_supplier_products.js
  • seeders/06_store_products.js
  • seeders/07_purchased_products.js
  • seeders/08_users.js
  • server/database/index.js
  • server/database/tests/index.test.js
  • server/gql/models/addresses/index.js
  • server/utils/testUtils/mockData.js
Additional comments not posted (2)
.eslintrc.js (2)

36-36: The max-params rule is set to limit functions to a maximum of five parameters, which should help in maintaining cleaner and more manageable function signatures.

Verification successful

The verification process confirms that there are no functions in the JavaScript codebase that exceed the five-parameter limit set by the max-params rule in .eslintrc.js. This ensures compliance with the ESLint configuration aimed at maintaining cleaner and more manageable function signatures.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that no functions exceed five parameters.

# Test: Search for functions with more than five parameters. Expect: No occurrences.
ast-grep --lang javascript --pattern $'function $_($_, $_, $_, $_, $_, $_) { $$$ }'

Length of output: 84


37-37: The complexity rule is appropriately set to a threshold of 10, which is a standard practice to ensure functions are not overly complex.

@@ -23,7 +23,7 @@ module.exports = {
'key-spacing': [2, { beforeColon: false, afterColon: true }],
'arrow-parens': ['error', 'as-needed'],
'arrow-body-style': [2, 'as-needed'],

camelcase: ['error', { properties: 'always', ignoreImports: false }],
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Several files in the codebase still use non-camelCase property names, which conflicts with the newly configured camelcase rule in .eslintrc.js. Here are some of the files that need attention:

  • webpack.server.config.js
  • seeders/08_users.js
  • server/utils/token.js
  • server/utils/testUtils/mockData.js
  • server/utils/tests/migrateUtils.test.js
  • server/utils/testUtils/index.js
  • seeders/06_store_products.js
  • seeders/07_purchased_products.js
  • seeders/03_stores.js
  • seeders/05_supplier_products.js
  • server/tests/index.test.js
  • server/index.js
  • server/middleware/gqlAuth/constants.js
  • server/utils/testUtils/dbConfig.js
  • server/database/models/store_products.js
  • server/database/models/suppliers.js
  • server/database/models/supplier_products.js
  • server/database/models/stores.js
  • server/database/models/purchased_products.js
  • server/database/models/products.js
  • server/database/models/index.js
  • server/database/models/addresses.js
  • server/gql/models/tests/supplierProducts/query.test.js
  • server/gql/models/tests/supplierProducts/mutation.test.js
  • server/database/models/users.js
  • server/gql/models/tests/purchasedProducts/query.test.js
  • server/gql/models/tests/purchasedProducts/mutation.test.js
  • server/gql/models/tests/products/query.test.js
  • seeders/04_supplier.js
  • server/gql/models/addresses/index.js
  • server/gql/models/aggregate/tests/purchasedProductsUtils.test.js
  • server/gql/models/aggregate/purchasedProductsUtils.js
  • server/gql/models/aggregate/tests/index.test.js
  • server/gql/models/aggregate/index.js
  • server/gql/models/tests/storeProducts/query.test.js
  • server/gql/models/tests/storeProducts/mutation.test.js

Please review and refactor these files to comply with the ESLint camelcase rule to avoid linting errors.

Analysis chain

The camelcase rule is correctly configured to enforce camelCase naming for all properties and includes checks on imports. Ensure that this change is reflected across the entire codebase to avoid linting errors.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all properties in JavaScript files adhere to camelCase naming convention.

# Test: Search for non-camelCase property names. Expect: No occurrences.
rg --type js --pcre2 '[a-z]+(_[a-z]+)+' --files-with-matches

Length of output: 1461

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant