Skip to content

Add golangci-lint rule to deprecate the processArgsAndFlags function #1178

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

Conversation

samtholiya
Copy link
Collaborator

@samtholiya samtholiya commented Mar 30, 2025

what

  • We are restricting the usage of os.Getenv
  • We are also depricating usage/enhancing function processArgsAndFlags

why

  • we should start using viper.BindEnv for new env variables
  • For flags we should start using cobra flags and also if possible bind to the viper. The binding would be mandatory post Config Core library #1174 pr

references

Summary by CodeRabbit

  • Chores
    • Introduced a new linter setting to enforce coding standards for environment variable access.
  • Refactor
    • Added deprecation notice for legacy command-line parameter handling, recommending a more robust flag processing approach.

@samtholiya samtholiya added the no-release Do not create a new release (wait for additional code changes) label Mar 30, 2025
Copy link

codecov bot commented Mar 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.29%. Comparing base (448bab5) to head (2aa391a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1178   +/-   ##
=======================================
  Coverage   28.29%   28.29%           
=======================================
  Files         182      182           
  Lines       21284    21284           
=======================================
  Hits         6022     6022           
  Misses      14312    14312           
  Partials      950      950           
Flag Coverage Δ
unittests 28.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtholiya samtholiya marked this pull request as ready for review March 30, 2025 13:10
@samtholiya samtholiya requested a review from a team as a code owner March 30, 2025 13:10
Copy link
Contributor

coderabbitai bot commented Mar 30, 2025

📝 Walkthrough

Walkthrough

This pull request updates the linting configuration and deprecates legacy flag parsing. The .golangci.yml file now includes a new forbidigo linter rule that prohibits the use of os.Getenv, advising the use of the viper package for configuration. Additionally, a deprecation notice is added to the processArgsAndFlags function in internal/exec/utils.go, which now encourages the use of the Cobra command flag parser while retaining its original implementation.

Changes

File Change Summary
.golangci.yml Added forbidigo linter rule to prohibit os.Getenv usage; instructs developers to use viper for configuration management.
internal/exec/utils.go Added deprecation notice to the processArgsAndFlags function advising transition to Cobra for flag parsing; function logic remains unchanged.

Assessment against linked issues

Objective Addressed Explanation
Forbid usage of os.Getenv (DEV-3112)
Replace custom flag parsing logic with Cobra (DEV-3112) Only a deprecation notice was added; migration logic is not implemented.

Possibly related PRs

  • Add GolangCI Lint Configuration for Better Code Quality #1078: The changes in the main PR, which introduce a new linter rule to forbid the use of os.Getenv, are related to the retrieved PR that also configures the forbidigo linter to prohibit specific function calls, including deprecated ones.
  • Add more lint rules #1082: The changes in the main PR, which add a specific linter rule to forbid the use of os.Getenv, are related to the retrieved PR that also modifies the .golangci.yml file to enhance linting rules, indicating a shared focus on linting configuration.
  • Losen lint rules #1084: The changes in the main PR introduce a new linter rule in the .golangci.yml file, while the retrieved PR modifies existing linter settings in the same file, indicating a direct relationship in their focus on linting configurations.

Suggested labels

patch, minor

Suggested reviewers

  • osterman
  • aknysh
  • milldr

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fb6ee3 and 2aa391a.

📒 Files selected for processing (2)
  • .golangci.yml (1 hunks)
  • internal/exec/utils.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/exec/utils.go
  • .golangci.yml
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Acceptance Tests (macos-latest, macos)
  • GitHub Check: Acceptance Tests (windows-latest, windows)
  • GitHub Check: Acceptance Tests (ubuntu-latest, linux)
  • GitHub Check: Summary

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 30, 2025
@osterman osterman changed the title create rule and depricate the processArgsAndFlags Add golangci-lint rule to deprecate the processArgsAndFlags function Mar 31, 2025
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
@osterman osterman merged commit 1283f07 into main Apr 1, 2025
50 checks passed
@osterman osterman deleted the feature/dev-3112-stop-usage-of-osgetenv-and-custom-flag-parsing-logic branch April 1, 2025 02:28
Copy link

github-actions bot commented Apr 1, 2025

These changes were released in v1.169.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-release Do not create a new release (wait for additional code changes) size/xs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants