creativeprojects / resticprofile

Configuration profiles manager and scheduler for restic backup
https://creativeprojects.github.io/resticprofile/
GNU General Public License v3.0
761 stars 33 forks source link

Linters #397

Closed creativeprojects closed 3 months ago

creativeprojects commented 3 months ago

Use golangci-lint to check for warnings during a PR

coderabbitai[bot] commented 3 months ago

Walkthrough

This update enhances the project's structure and robustness by introducing error handling, improving testing procedures, and integrating a linting job into the CI pipeline. Key changes include refining function signatures, modifying regex patterns for better readability, and streamlining control flows across various components. Collectively, these modifications aim to improve code maintainability, clarity, and overall quality while ensuring a cleaner codebase prior to testing.

Changes

File(s) Change Summary
.github/workflows/build.yml Added a golangci-lint job to the CI pipeline for Go code linting before tests.
.golangci.yml Configured gosec linter with exclusions for specific rules.
calendar/event_parse.go Enhanced error handling in parseSecond and setMidnight functions to improve robustness.
calendar/value.go, calendar/value_test.go Renamed parameters for clarity in Value struct-related functions and improved error handling in tests.
commands.go Simplified the elevated function signature and improved regex readability for command arguments.
complete_test.go Simplified the iteration over command.flags in TestCompleter.
config/info.go, config/info_test.go Removed redundant checks and improved test assertions for clarity and maintainability.
config/jsonschema/model.go Changed walkTypes function to have no return value, focusing on its operational side effects.
config/profile.go, config/profile_test.go Updated unused parameter naming for clarity in InitSection and streamlined logic in tests.
remote/client.go, remote/server.go Enhanced error handling and added linter directives for HTTP requests.
update.go Improved error handling in the confirmAndSelfUpdate function for better robustness.
monitor/mocks/OutputAnalysis.go, schedule/mocks/Handler.go Updated mockery version in generated files.

Sequence Diagram(s)

sequenceDiagram
    participant CI as CI Pipeline
    participant L as Linter
    participant T as Tests
    participant A as Application

    CI->>L: Run golangci-lint
    L-->>CI: Linting results
    CI->>T: Run Tests
    T-->>CI: Test results
    CI-->>A: CI Status

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `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.` - `@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 as 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 resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configuration 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 59.47712% with 62 lines in your changes missing coverage. Please review.

Project coverage is 72.24%. Comparing base (0ad1b68) to head (57e1bde). Report is 2 commits behind head on master.

Files Patch % Lines
calendar/event_parse.go 33.33% 8 Missing and 4 partials :warning:
wrapper.go 29.41% 8 Missing and 4 partials :warning:
commands.go 14.29% 6 Missing :warning:
schtasks/taskscheduler.go 16.67% 5 Missing :warning:
crond/mock/main.go 0.00% 4 Missing :warning:
schedule/handler_windows.go 0.00% 3 Missing and 1 partial :warning:
remote/client.go 57.14% 2 Missing and 1 partial :warning:
remote/server.go 72.73% 2 Missing and 1 partial :warning:
shell/plain_summary.go 25.00% 2 Missing and 1 partial :warning:
config/show.go 0.00% 1 Missing and 1 partial :warning:
... and 6 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #397 +/- ## ========================================== + Coverage 71.79% 72.24% +0.45% ========================================== Files 127 127 Lines 12900 12925 +25 ========================================== + Hits 9261 9337 +76 + Misses 3226 3160 -66 - Partials 413 428 +15 ``` | [Flag](https://app.codecov.io/gh/creativeprojects/resticprofile/pull/397/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Fred) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/creativeprojects/resticprofile/pull/397/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Fred) | `72.24% <59.48%> (+0.45%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Fred#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.