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

dangling ref #109

Merged
merged 2 commits into from
Dec 19, 2024
Merged

dangling ref #109

merged 2 commits into from
Dec 19, 2024

Conversation

PhilipDeegan
Copy link
Owner

@PhilipDeegan PhilipDeegan commented Dec 19, 2024

Summary by CodeRabbit

  • New Features

    • Updated versioning date to December 19, 2024.
    • Enhanced error handling and logging for build processes.
    • Improved thread safety during test builds.
  • Bug Fixes

    • Refined error handling for invalid conditions and cyclical dependencies.
  • Refactor

    • Simplified variable declarations across multiple methods for improved readability.
  • Documentation

    • No changes made to documentation.

Copy link

coderabbitai bot commented Dec 19, 2024

Warning

Rate limit exceeded

@PhilipDeegan has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 23 minutes and 55 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 31e1b46 and cff0609.

📒 Files selected for processing (2)
  • .github/workflows/build_osx.yml (1 hunks)
  • .github/workflows/release.yml (0 hunks)

Walkthrough

The pull request encompasses modifications across several files in the Maiken build system. The changes primarily focus on refining error handling, updating variable declarations, and improving type semantics. The configuration file mkn.yaml has been updated with a new date, while source files like maiken.cpp, build/bin.cpp, dep.cpp, and validation.cpp have undergone subtle modifications in method signatures, variable declarations, and error handling mechanisms.

Changes

File Change Summary
mkn.yaml Updated DATE property from 07-OCT-2024 to 19-DEC-2024
src/maiken.cpp - Modified setSuper method variable declaration
- Enhanced error handling in populateMaps and addIncludeLine methods
- Added cyclical dependency check in cyclicCheck method
src/maiken/build/bin.cpp - Updated build_exe method with improved error handling and logging
- Modified method signatures for buildExecutable and buildLibrary to include exception handling
- Added mutex for thread safety in buildTest method
src/maiken/dep.cpp - Changed variable type from std::string const& to auto const in buildDepVec method
src/maiken/validation.cpp - Updated variable declarations in PRE_BUILD and preSetupValidation methods
- Maintained existing validation and error handling logic

Poem

🐰 A Rabbit's Build System Ballad 🔧

In YAML's realm, a date takes flight,
From October to December's bright
Code refactored, errors tamed with care,
Variables dancing without a snare
Maiken builds on, with rabbit's might! 🚀


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

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.

Copy link

@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 (5)
src/maiken/build/bin.cpp (3)

125-125: Consider explicit type declaration for better readability.

While using auto const is valid here, an explicit std::string const might make the intended type more obvious to readers, especially since this is storing a project name which is a core concept.

-  auto const name(out.empty() ? project().root()[STR_NAME].Scalar() : out);
+  std::string const name(out.empty() ? project().root()[STR_NAME].Scalar() : out);

Line range hint 193-194: Consider making the thread pool timeout configurable.

The hardcoded timeout of 10 seconds (10000000 microseconds) might not be suitable for all environments or test suites. Consider:

  1. Making this value configurable through application settings
  2. Using a constant or configuration value instead of a magic number
-  ctp.finish(10000000);  // 10 milliseconds
+  static constexpr auto DEFAULT_TIMEOUT_US = 10000000;  // 10 seconds
+  ctp.finish(AppVars::INSTANCE().getThreadPoolTimeout(DEFAULT_TIMEOUT_US));

Line range hint 271-272: Enhance error message with more context.

The error message when encountering an unsupported file type could be more helpful by including:

  1. The list of supported file types
  2. The current configuration context
-    KEXCEPTION("Unable to handle artifact: \"" + lang + "\" - type is not in file list");
+    std::string supported_types;
+    for (const auto& type : fs) {
+      if (!supported_types.empty()) supported_types += ", ";
+      supported_types += type.first;
+    }
+    KEXCEPTION("Unable to handle artifact: \"" + lang + "\" - supported types are: [" + supported_types + "]");
src/maiken.cpp (2)

Line range hint 201-206: Enhance error message in catch block

The current error message only shows the exception message and a generic "Possible super cycle detected" message. Consider including more context about what operation failed.

     } catch (std::exception const& e) {
-        KLOG(ERR) << e.what();
-        KEXIT(1, "Possible super cycle detected: " + project().dir().real());
+        KLOG(ERR) << "Failed to resolve super project: " << e.what();
+        KEXIT(1, "Failed to process super reference (possible cycle detected) in: " + project().dir().real());
     }

Line range hint 214-214: Remove empty comment

The empty comment // serves no purpose and should be removed.

-      //
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 15abf46 and 31e1b46.

📒 Files selected for processing (5)
  • mkn.yaml (1 hunks)
  • src/maiken.cpp (1 hunks)
  • src/maiken/build/bin.cpp (1 hunks)
  • src/maiken/dep.cpp (1 hunks)
  • src/maiken/validation.cpp (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • mkn.yaml
🔇 Additional comments (4)
src/maiken/dep.cpp (1)

109-109: 🛠️ Refactor suggestion

Consider keeping the reference type for better performance.

The change from reference to value type might introduce unnecessary string copies. Since Scalar() returns a std::string, and the value is only used for reading within the scope, using a const reference would be more efficient.

-    auto const name(a.project().root()[STR_NAME].Scalar());
+    std::string const& name(a.project().root()[STR_NAME].Scalar());

Likely invalid or redundant comment.

src/maiken/validation.cpp (1)

68-68: LGTM: Simple string comparison use case.

The change to value type is acceptable here as the string is only used for simple comparisons.

src/maiken.cpp (2)

196-196: LGTM: Good choice using auto const instead of auto const&

Using auto const is more efficient here as the YAML scalar value is small and copying avoids maintaining a reference to YAML's internal data structures.


Line range hint 196-232: LGTM: Robust error handling for super references

The code thoroughly validates super references by:

  1. Checking for self-references
  2. Validating file/directory existence
  3. Detecting cycles in the super chain
  4. Properly handling both file and directory cases

This makes the system more robust and provides clear error messages.

@@ -130,7 +130,7 @@ void maiken::Application::preSetupValidation() KTHROW(maiken::Exception) {
Validator::PRE_BUILD(*this, project().root());
std::vector<std::string> profiles;
for (auto const& profile : project().root()[STR_PROFILE]) {
std::string const& p(profile[STR_NAME].Scalar());
auto const p(profile[STR_NAME].Scalar());
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Maintain reference type for frequently used value.

The profile name is used multiple times in string comparisons and error messages. Using a value type here could lead to unnecessary copies.

-    auto const p(profile[STR_NAME].Scalar());
+    std::string const& p(profile[STR_NAME].Scalar());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
auto const p(profile[STR_NAME].Scalar());
std::string const& p(profile[STR_NAME].Scalar());

@PhilipDeegan PhilipDeegan merged commit 2abcae0 into master Dec 19, 2024
6 checks passed
@PhilipDeegan PhilipDeegan deleted the werror branch December 19, 2024 12:36
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.

1 participant