Skip to content

Conversation

@jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Aug 11, 2025

PR-Codex overview

This PR focuses on enhancing the configuration for Solidity contract coverage in a Hardhat project. It introduces new environment variable handling and adjustments to the optimizer settings.

Detailed summary

  • In contracts/.solcover.js: Added irMinimum: true.
  • In contracts/hardhat.config.ts: Changed viaIR to depend on process.env.VIA_IR.
  • In contracts/scripts/coverage.sh: Added export VIA_IR=false before running coverage commands.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Tests

    • Enabled IR-minimum mode in coverage configuration to improve coverage run compatibility.
    • Coverage workflow now exports a variable allowing IR-based compilation to be disabled during coverage runs for more consistent reports.
  • Chores

    • Added an environment-controlled toggle so IR usage can be turned off without changing defaults.

@jaybuidl jaybuidl added Type: Maintenance 🚧 Type: Toolchain ⚒️ Build tools configuration, CI/CD labels Aug 11, 2025
@netlify
Copy link

netlify bot commented Aug 11, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit b8628bb
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/689a7c57d7e82b0008423dde
😎 Deploy Preview https://deploy-preview-2082--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Aug 11, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit b8628bb
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/689a7c576518a20007e22e61
😎 Deploy Preview https://deploy-preview-2082--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Aug 11, 2025

Deploy Preview for kleros-v2-testnet-devtools ready!

Name Link
🔨 Latest commit b8628bb
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/689a7c57a03ca60008b0d54f
😎 Deploy Preview https://deploy-preview-2082--kleros-v2-testnet-devtools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds irMinimum: true to solcover config, makes Hardhat viaIR controlled by process.env.VIA_IR !== "false", and exports VIA_IR=false unconditionally in the coverage script before building/running coverage.

Changes

Cohort / File(s) Summary of changes
Solcover configuration
contracts/.solcover.js
Adds irMinimum: true to the exported solcover configuration object.
Coverage script
contracts/scripts/coverage.sh
Inserts export VIA_IR=false (unconditional) after the "Building contracts with Hardhat..." echo, before yarn build and coverage steps.
Hardhat config
contracts/hardhat.config.ts
Replaces viaIR: true with viaIR: process.env.VIA_IR !== "false", making IR usage controllable via the VIA_IR environment variable.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant Script as contracts/scripts/coverage.sh
  participant Env as Environment
  participant Build as yarn build
  participant HHCfg as hardhat.config.ts
  participant Coverage as npx hardhat coverage

  Dev->>Script: run coverage.sh
  Script->>Env: export VIA_IR=false
  Script->>Build: yarn build
  Build->>HHCfg: hardhat loads config (reads process.env.VIA_IR)
  HHCfg->>Build: viaIR = false (VIA_IR="false")
  Script->>Coverage: npx hardhat coverage
  Coverage->>HHCfg: uses solc viaIR=false and solcover config (irMinimum: true)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

Package: Contracts

Poem

I nibble at flags and hop through code,
A tiny export sets the IR mode.
Config added, a quiet little tweak,
Builds pause, then hustle — coverage will speak.
Thump-thump, I dance — tests pass cheek to cheek! 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 464568e and b8628bb.

📒 Files selected for processing (3)
  • contracts/.solcover.js (1 hunks)
  • contracts/hardhat.config.ts (1 hunks)
  • contracts/scripts/coverage.sh (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/coverage-script-again-ffs

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
  • 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 explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

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 or @coderabbitai title anywhere in the PR title to generate the title automatically.

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 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.

@jaybuidl jaybuidl force-pushed the fix/coverage-script-again-ffs branch from b021221 to 7e107cc Compare August 11, 2025 22:00
@netlify
Copy link

netlify bot commented Aug 11, 2025

Deploy Preview for kleros-v2-university failed. Why did it fail? →

Name Link
🔨 Latest commit b8628bb
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-university/deploys/689a7c5792ccf80008c575ba

Copy link
Contributor

@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

🧹 Nitpick comments (1)
contracts/scripts/coverage.sh (1)

32-32: Use the same portable sed helper consistently

This invocation uses -i -e, which breaks on BSD sed. Reuse the sedi helper for consistency and portability.

- sed -i -e 's/\/.*\/kleros-v2\/contracts\///g' coverage/lcov-hardhat.info
+ sedi 's/\/.*\/kleros-v2\/contracts\///g' coverage/lcov-hardhat.info
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a130a6a and 7e107cc.

📒 Files selected for processing (2)
  • contracts/.solcover.js (1 hunks)
  • contracts/scripts/coverage.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: contracts-testing
🔇 Additional comments (1)
contracts/.solcover.js (1)

10-10: Confirmed: irMinimum is a supported solidity-coverage option

The irMinimum boolean flag is recognized and defaults to false. It can speed up test runs when using solc’s viaIR mode but may cause compilation failures in some setups—enable it only if your project still compiles under coverage with viaIR.

No changes required.

fi

# Generate the Hardhat coverage report
sed -i '' 's/\(viaIR: \)true/\1false/' hardhat.config.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Make the viaIR toggle robust, cross-platform, and reversible

Current sed:

  • May fail across macOS/Linux due to -i '' usage.
  • Matches only viaIR: true with a single space; misses variations like extra spaces.
  • Permanently mutates hardhat.config.ts (no revert), leaving a dirty tree locally.

Suggestions:

  • Use a cross-platform sed wrapper.
  • Match flexible whitespace.
  • Revert the change on exit with a trap.

Apply within this hunk:

- sed -i '' 's/\(viaIR: \)true/\1false/' hardhat.config.ts
+ # Disable viaIR during coverage with a portable sed and auto-restore on exit
+ sedi -E 's/(viaIR:[[:space:]]*)true/\1false/' hardhat.config.ts
+ trap 'sedi -E "s/(viaIR:[[:space:]]*)false/\1true/" hardhat.config.ts' EXIT

Add this helper near the top of the script (outside this hunk):

# Portable in-place sed (GNU vs BSD)
sedi() {
  if sed --version >/dev/null 2>&1; then
    sed -i -E "$@"
  else
    sed -i '' -E "$@"
  fi
}

Alternative (cleaner): avoid sed entirely by toggling viaIR in hardhat.config.ts when process.env.COVERAGE is set by the coverage task.

🤖 Prompt for AI Agents
In contracts/scripts/coverage.sh around line 22, the current sed call is
non-portable, only matches a single-space pattern, and permanently modifies
hardhat.config.ts; replace it by adding a portable sedi helper near the top of
the script (outside this hunk) that detects GNU vs BSD sed, then use that helper
to run a regex with flexible whitespace matching (e.g. match viaIR:\s*true) to
toggle true->false, create a temporary backup or copy before modifying, and
install a trap to restore the original file on EXIT (and on ERR/INT) so the
change is reversible and leaves no dirty tree; alternatively mention switching
to an environment-variable-based toggle in hardhat.config.ts and avoid sed
entirely.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (2)
contracts/hardhat.config.ts (1)

31-31: Make VIA_IR parsing more robust (accept common “falsey” values, case-insensitive)

Today only the exact string "false" disables IR. Consider accepting common variants and casing (e.g., 0, off, no, FALSE), while still defaulting to true.

-          viaIR: process.env.VIA_IR !== "false", // Defaults to true
+          // Defaults to true unless explicitly disabled
+          viaIR: !["false", "0", "off", "no"].includes((process.env.VIA_IR ?? "").toLowerCase()),
contracts/scripts/coverage.sh (1)

24-27: Scope VIA_IR to the commands instead of exporting it globally

Inline the env var per command so it won’t leak if the script is sourced or grows later. Nice improvement moving away from sed—this avoids the prior cross-platform pitfalls.

- export VIA_IR=false
- yarn build
+ VIA_IR=false yarn build
  echo "Running Hardhat coverage..."
- yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --show-stack-traces --testfiles "test/**/*.ts"
+ VIA_IR=false yarn hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --show-stack-traces --testfiles "test/**/*.ts"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e107cc and 464568e.

📒 Files selected for processing (2)
  • contracts/hardhat.config.ts (1 hunks)
  • contracts/scripts/coverage.sh (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: SonarCloud
  • GitHub Check: Redirect rules - kleros-v2-neo
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Redirect rules - kleros-v2-university
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-neo
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-university
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-neo
  • GitHub Check: Pages changed - kleros-v2-university
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
  • GitHub Check: Analyze (javascript)
  • GitHub Check: SonarCloud
  • GitHub Check: contracts-testing

@jaybuidl jaybuidl force-pushed the fix/coverage-script-again-ffs branch from 464568e to b8628bb Compare August 11, 2025 23:27
@jaybuidl jaybuidl merged commit b8628bb into dev Aug 11, 2025
11 of 18 checks passed
@jaybuidl jaybuidl deleted the fix/coverage-script-again-ffs branch August 11, 2025 23:28
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Maintenance 🚧 Type: Toolchain ⚒️ Build tools configuration, CI/CD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants