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

Fixed lint errors #1270

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Fixed lint errors #1270

wants to merge 6 commits into from

Conversation

backsapc
Copy link
Contributor

@backsapc backsapc commented Feb 25, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling in event processing to halt execution when issues are detected.
    • Improved validation logic for data outputs to ensure accurate equivalence checks.
    • Strengthened error handling during directory cloning and template execution processes.
  • Chores

    • Streamlined internal logging and output routines.
    • Strengthened error propagation in utility processes to boost overall system reliability.
    • Updated gRPC connection establishment method for improved functionality.
    • Expanded workflow triggers to include changes in the "prophet" directory.

@backsapc backsapc requested a review from mn13 February 25, 2025 09:24
Copy link
Contributor

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

Walkthrough

The pull request introduces modifications across several files. Lint suppression comments (e.g., //nolint:all) have been added to ignore linter warnings on specific lines related to error output and standard output. Error handling has been improved in various functions, including early returns for error cases and enhanced error propagation during recursive operations. Additionally, a byte slice comparison was revised to use a more direct equality check.

Changes

File(s) Change Summary
cmd/shield_repl/main.go
prophet/handlers/pricepred/pricepred.go
precompiles/warden/events.go
Added lint suppression comments (//nolint:all) to designated output and error handling lines to suppress linter warnings without altering the program’s behavior.
precompiles/async/events.go
tests/framework/files/files.go
Enhanced error handling by introducing immediate error checks and early returns, ensuring that errors from function calls (topic creation and directory cloning/template execution) are promptly propagated.
prophet/handlers/echo/echo.go Modified the logic for byte slice comparison by replacing bytes.Compare(input, output) != 0 with the more direct !bytes.Equal(input, output) check.
precompiles/common/events.go Introduced a new function ParseSdkEventSafe to improve error handling in event processing, allowing errors from the fillEvent function to propagate back to the caller.
tests/framework/exec/warden_node.go Updated the method GRPCClient to replace grpc.Dial with grpc.NewClient, changing the gRPC connection establishment method while maintaining the same error handling structure.
.github/workflows/wardend.yaml Added "prophet/" path to push and pull_request triggers and updated the modules environment variable to include "prophet/" and "precompiles/**" paths, enhancing workflow scope.

Sequence Diagram(s)

sequenceDiagram
    participant C as Caller
    participant G as GetCreateFutureEvent
    participant M as MakeTopic

    C->>G: Call GetCreateFutureEvent(event)
    G->>M: MakeTopic(typedEvent.GetId())
    alt Error occurs
        M-->>G: Return error
        G->>C: Return nil, error
    else No error
        M-->>G: Return topic
        G->>M: Create additional topic (topics[2])
        G->>C: Return event with topics
    end
Loading
sequenceDiagram
    participant T as Test Function
    participant C as CloneDir
    participant E as Template Executor

    T->>C: Invoke CloneDir(directory)
    C->>C: Recursively clone subdirectories
    alt Error in recursive clone
        C-->>T: Return error
    else
        C->>E: Execute template for files
        alt Error in template execution
            E-->>C: Return error
            C-->>T: Return error
        else
            C->>T: Complete and return cloned directory
        end
    end
Loading

Suggested labels

test, docs

Suggested reviewers

  • Svetomech
  • mn13

📜 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 15c779f and a18e8b8.

📒 Files selected for processing (1)
  • .github/workflows/wardend.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: test
  • GitHub Check: release
  • GitHub Check: test
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
.github/workflows/wardend.yaml (3)

11-11: Review: Addition of "prophet/" path for push events.**
This change ensures that updates within the "prophet" directory will trigger the workflow on push events. The inclusion is consistent with the new modules being added.


19-19: Review: Addition of "prophet/" path for pull_request events.**
Including the "prophet/**" path in pull_request triggers is a good update to catch PRs affecting the "prophet" directory. This aligns well with the expanded directory scope required by recent changes.


22-22: Review: Updated modules environment variable.
The modules environment variable now includes "./prophet/..." and "./precompiles/...", which broadens the testing and linting scope to cover these directories. This update is appropriate given the intended project expansion.


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>, 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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 to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai 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.

Copy link

Hey @backsapc and thank you for opening this pull request! 👋🏼

It looks like you forgot to add a changelog entry for your changes. Make sure to add a changelog entry in the 'CHANGELOG.md' file.

Copy link
Contributor

@mn13 mn13 left a comment

Choose a reason for hiding this comment

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

Looks like we can replace grpc.Dial with grpc.NewClient also

@@ -417,7 +417,7 @@ func (p Precompile) GetUpdateKeychainEvent(ctx sdk.Context, _ *common.Address, e
var marshaled []byte
if err := precommon.ParseSdkEvent(eventUpdateKeychain, func(m proto.Message) {
marshaled, err = proto.Marshal(m)
typedEvent.Unmarshal(marshaled)
typedEvent.Unmarshal(marshaled) //nolint:errcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change ParseSdkEvent to return error from callback and check err in this row?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -97,7 +97,7 @@ func (s PricePredictorSolidity) Execute(ctx context.Context, input []byte) ([]by

var backtestingRes *BacktestingResponse
if len(inputData.Metrics) > 0 {
res, err := s.c.Backtesting(ctx, BacktestingRequest{
res, err := s.c.Backtesting(ctx, BacktestingRequest{ //nolint:all
Copy link
Contributor

Choose a reason for hiding this comment

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

S1016: should convert req (type PredictRequest) to BacktestingRequest instead of using struct literal (gosimple)

Can you please make method that will convert PredictRequest to BacktestingRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

vercel bot commented Feb 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
warden-help-center ⬜️ Ignored (Inspect) Visit Preview Feb 25, 2025 1:53pm

mn13
mn13 previously approved these changes Feb 25, 2025
Copy link
Contributor

@mn13 mn13 left a comment

Choose a reason for hiding this comment

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

Thanks! LTTM

@backsapc backsapc requested a review from Pitasi February 25, 2025 13:58
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.

2 participants