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

New rule: validate async intervals #139

Merged
merged 1 commit into from
Mar 17, 2024
Merged

New rule: validate async intervals #139

merged 1 commit into from
Mar 17, 2024

Conversation

nunnatsa
Copy link
Owner

Description

The linter now supports new optional rul (turned off by default). This rule validates the async functions' timeout and polling arguments.

The linter checks for three things:

  1. best effort: if the time interval is known (when using integr literals or time.Duration values), the linter validates that the timeout is not shorter than the polling interval.

  2. Forces the timeout and the polling arguments of the Eventually and Consistently functions, to be of type time.Duration.

    Best effort auto-fix: in cases that the linter can do that, e.g. for an integer value, it suggests replacing this value with a multiply with time.Second.

  3. Forces up to one timeout and up to one polling arguments.

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #129

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Added test case and related test data
  • Update the functional test

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I ran golangci-lint

The linter now supports new optional rul (turned off by default). This
rule validates the async functions' timeout and polling arguments.

The linter checks for three things:
1. best effort: if the time interval is known (when using integr
   literals or `time.Duration` values), the linter validates that
   the timeout is not shorter than the polling interval.
2. Forces the timeout and the polling arguments of the `Eventually` and
   `Consistently` functions, to be of type `time.Duration`.

   Best effort auto-fix: in cases that the linter can do that, e.g. for
   an integer value, it suggests replacing this value with a multiply
   with time.Second.
3. Forces up to one timeout and up to one polling arguments.
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 8317036138

Details

  • 11 of 11 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 67.11%

Totals Coverage Status
Change from base Build 8280785109: 0.2%
Covered Lines: 202
Relevant Lines: 301

💛 - Coveralls

@nunnatsa nunnatsa merged commit 2973d69 into main Mar 17, 2024
1 check passed
@nunnatsa nunnatsa deleted the timing branch March 18, 2024 05:35
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.

[Enhancement] Lint Eventually timeout and polling durations
2 participants