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

chore: Cleanup #1440

Merged
merged 9 commits into from
Nov 13, 2024
Merged

chore: Cleanup #1440

merged 9 commits into from
Nov 13, 2024

Conversation

oskogstad
Copy link
Collaborator

@oskogstad oskogstad commented Nov 12, 2024

  • Added ref. to GitHub issue
  • Typos
  • Whitespace
  • Collection expression
  • const
  • Renaming

@oskogstad oskogstad requested a review from a team as a code owner November 12, 2024 19:08
Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

📝 Walkthrough

Walkthrough

This pull request includes various modifications across multiple files, primarily focusing on improving documentation comments, correcting formatting issues, and streamlining code structure without altering the underlying functionality. Key changes involve the refinement of XML documentation comments, the introduction of expression-bodied members for methods, and the removal of unused import statements. Additionally, several classes and methods have undergone minor adjustments in comments for clarity and consistency, particularly regarding terminology and formatting.

Changes

File Path Change Summary
src/Digdir.Domain.Dialogporten.Application/Common/Behaviours/DomainContextBehaviour.cs Updated XML documentation comments by removing trailing spaces.
src/Digdir.Domain.Dialogporten.Application/Common/Extensions/OptionExtensions/FluentValidationOptions.cs Adjusted XML documentation comment for constructor to remove unnecessary line break.
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogSeenLogs/Queries/Search/MappingProfile.cs Removed an extraneous line in the constructor of MappingProfile.
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/MappingProfile.cs Removed mapping configuration for List<DialogTransmissionContent>? to ContentDto?.
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Search/MappingProfile.cs Updated mapping to use a custom converter for List<DialogTransmissionContent>? to ContentDto?.
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Search/SearchDialogQuery.cs Minor formatting change in XML documentation comment for SystemLabel property.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Get/MappingProfile.cs Removed an extraneous line in the constructor of MappingProfile.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Search/MappingProfile.cs Removed a blank line in the constructor of MappingProfile.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/MappingProfile.cs Removed a blank line between mapping configurations.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Search/MappingProfile.cs Updated mapping to use a custom converter for List<DialogTransmissionContent>? to ContentDto?.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs Enhanced error handling and validation logic in UpdateDialogCommandHandler.
src/Digdir.Domain.Dialogporten.ChangeDataCapture/ICdcSink.cs Corrected a typographical error in a comment.
src/Digdir.Domain.Dialogporten.ChangeDataCapture/appsettings.Development.json Removed trailing whitespace in comments.
src/Digdir.Domain.Dialogporten.Domain/Common/EventPublisher/IDomainEvent.cs Updated documentation comments for clarity.
src/Digdir.Domain.Dialogporten.Domain/Common/Exceptions/DomainException.cs Streamlined constructor definition.
src/Digdir.Domain.Dialogporten.Domain/DialogEndUserContexts/Entities/DialogEndUserContext.cs Minor formatting adjustment in a comment.
src/Digdir.Domain.Dialogporten.Domain/Dialogs/Entities/DialogEntity.cs Removed unused using directive.
src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogCreatedDomainEvent.cs Reformatted parameters for improved readability.
src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogSeenDomainEvent.cs Reformatted parameters for improved readability.
src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogUpdatedDomainEvent.cs Reformatted parameters for improved readability.
src/Digdir.Domain.Dialogporten.Domain/Localizations/LocalizationSet.cs Minor formatting change in a comment.
src/Digdir.Domain.Dialogporten.GraphQL/Common/Authorization/AllowAnonymousHandler.cs Corrected spelling in comment documentation.
src/Digdir.Domain.Dialogporten.GraphQL/Common/Constants.cs Removed a blank line at the end of the file.
src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/MappingProfile.cs Removed unused import statement.
src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/AltinnAuthorizationClient.cs Modified caching mechanism and updated method signatures.
src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/DialogDetailsAuthorizationRequest.cs Corrected a typographical error in a comment.
src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/DialogEntityExtensions.cs Updated comments for clarity.
src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/LocalDevelopmentAltinnAuthorization.cs Refactored methods to use expression-bodied members and updated comments.
src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/ResourceRegistryClient.cs Corrected a grammatical error in a comment.
src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs Minor comment adjustment.
src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/ValueConverters/DateTimeOffsetConverter.cs Added a newline at the end of the file.
src/Digdir.Domain.Dialogporten.Infrastructure/UnitOfWork.cs Simplified method syntax without changing functionality.
src/Digdir.Domain.Dialogporten.Janitor/Program.cs Corrected casing in comments for consistency.
src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs Corrected spelling in comment documentation.
src/Digdir.Library.Entity.Abstractions/Features/Aggregate/IAggregateChangedHandler.cs Introduced new interface IAggregateRestoredHandler.
src/Digdir.Library.Entity.Abstractions/Features/Identifiable/IdentifiableExtensions.cs Refactored methods for clarity and updated GUID handling.
src/Digdir.Library.Entity.Abstractions/Features/Lookup/AbstractLookupEntity.cs Updated documentation comment for constructor parameter.
src/Digdir.Library.Entity.Abstractions/Features/Lookup/ILookupEntity.cs Adjusted comments for clarity and consistency.
src/Digdir.Library.Entity.Abstractions/Features/SoftDeletable/ISoftDeletableEntity.cs Updated comments for consistent terminology.
src/Digdir.Library.Entity.Abstractions/IJoinEntity.cs Minor textual modifications in documentation comments.
src/Digdir.Library.Entity.EntityFrameworkCore/EntityLibraryEfCoreExtensions.cs Corrected typographical errors in documentation comments.
src/Digdir.Library.Entity.EntityFrameworkCore/Features/Aggregate/AggregateExtensions.cs Updated comments for clarity and corrected typographical errors.
src/Digdir.Library.Entity.EntityFrameworkCore/Features/Lookup/LookupEntityExtensions.cs Reformatted constructor for MockLookupEntity for clarity.
src/Digdir.Library.Entity.EntityFrameworkCore/Features/SoftDeletable/SoftDeletableExtensions.cs Renamed a private field and updated comments for consistency.
src/Digdir.Tool.Dialogporten.Benchmarks/TokenGenerationBenchmark.cs Updated comments for consistency in hyphenation.
src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs Refactored method to expression-bodied member and removed unused import.
src/Digdir.Tool.Dialogporten.GenerateFakeData/README.md Minor textual modifications for clarity.
src/Digdir.Tool.Dialogporten.SlackNotifier/Common/Extensions.cs Added clarifying comment in ToQueryLink method.
tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Common/IHierarchyTestNodeBuilder.cs Simplified method implementations to expression-bodied members.
tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/Common/Utils/ApplicationEventHandlerUtilsTests.cs Corrected comment formatting issue in test method.
tests/Digdir.Tool.Dialogporten.SlackNotifier.Tests/AsciiTableFormatterTests.cs Modified list initialization syntax and declared constants with const.

Possibly related PRs

Suggested reviewers

  • MagnusSandgren

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7b28f54 and 3d3bc3a.

📒 Files selected for processing (1)
  • docs/schema/V1/swagger.verified.json (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/schema/V1/swagger.verified.json

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.

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
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: 2

🧹 Outside diff range and nitpick comments (13)
src/Digdir.Library.Entity.Abstractions/Features/Aggregate/IAggregateChangedHandler.cs (2)

Line range hint 51-53: Fix incorrect documentation comment

The summary comment for IAggregateRestoredHandler incorrectly states "deletion" instead of "restoration".

Apply this diff to fix the documentation:

 /// <summary>
-/// Defines an entity handler for handling the deletion of its own aggregate.
+/// Defines an entity handler for handling the restoration of its own aggregate.
 /// </summary>

Line range hint 4-8: Consider including IAggregateRestoredHandler in the composite interface

The new IAggregateRestoredHandler interface follows the same pattern as other aggregate handlers but is not included in the composite IAggregateChangedHandler interface. Consider whether restoration should be part of the standard aggregate lifecycle.

If restoration is a core lifecycle event, apply this diff:

 public interface IAggregateChangedHandler :
     IAggregateCreatedHandler,
     IAggregateUpdatedHandler,
-    IAggregateDeletedHandler;
+    IAggregateDeletedHandler,
+    IAggregateRestoredHandler;
tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Common/IHierarchyTestNodeBuilder.cs (1)

Line range hint 13-71: Consider documenting thread-safety limitations.

The HierarchyTestNodeBuilder maintains internal state through _nodes and _current. While this is typically fine for test code, it would be helpful to document that this builder is not thread-safe to prevent potential misuse in parallel test scenarios.

Add a class-level documentation comment:

+/// <summary>
+/// Builder for creating test hierarchy structures. This class is not thread-safe and should not be shared between threads.
+/// </summary>
internal sealed class HierarchyTestNodeBuilder : IHierarchyTestNodeBuilder
src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/LocalDevelopmentAltinnAuthorization.cs (2)

23-25: Consider marking the method as static and using nameof for action retrieval.

The expression-bodied syntax is a good improvement for readability. However, since this method doesn't use any instance members, consider addressing the CA1822 warning by marking it as static instead of suppressing it.

- [SuppressMessage("Performance", "CA1822:Mark members as static")]
- public Task<DialogDetailsAuthorizationResult> GetDialogDetailsAuthorization(
+ public static Task<DialogDetailsAuthorizationResult> GetDialogDetailsAuthorization(

32-32: LGTM! Consider enhancing the comment with parameter limits.

The comment clarity is improved. Consider adding information about the implemented limits (1000 for parties/resources, 30 for roles) to make it more informative for developers.

- // If one and/or the other is supplied this will limit the resources and parties to the ones supplied
+ // If one and/or the other is supplied this will limit the resources and parties to the ones supplied
+ // (limited to max 1000 parties/resources and 30 roles)
src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs (2)

Line range hint 10-15: Improve documentation clarity and professionalism

The current documentation could be enhanced for better clarity and professionalism:

  1. Avoid informal language like "weird behavior"
  2. Complete the explanation of what exactly is being set
  3. Clarify the purpose and impact of the workaround

Consider this improved version:

-    /// This is a workaround for a bug/weird behavior in FastEndpoints where examples
-    /// to the RequestExamples array are not added to the OpenAPI document.
-    /// Each SwaggerConfig file implements a GetExample method that returns the example
-    ///
-    /// This sets for those who have a request body.
+    /// Implements a workaround for a FastEndpoints limitation where request examples
+    /// are not automatically added to the OpenAPI document. This method manually sets
+    /// the example bodies for endpoints that have request bodies, using examples
+    /// provided by the corresponding SwaggerConfig implementation.

Line range hint 38-42: Address technical debt: Hard-coded operation ID check

The current implementation contains a hard-coded check for a specific operation ID, which limits extensibility and maintainability.

Consider implementing a more flexible solution:

  1. Create a registry/map of operation IDs to their example providers
  2. Add proper error handling for unknown operation IDs
  3. Create a GitHub issue to track this technical debt

Would you like me to:

  1. Generate a more flexible implementation?
  2. Create a GitHub issue to track this technical debt?
tests/Digdir.Tool.Dialogporten.SlackNotifier.Tests/AsciiTableFormatterTests.cs (2)

70-74: Consider using a more explicit null test approach

While null! suppresses the nullable warning, consider making the test intention clearer by either:

  1. Using a nullable type declaration
  2. Adding a comment explaining the null test case
 List<List<object>> rows =
 [
     ["Header1"],
-    [null!]
+    [null as object] // Explicitly testing null handling
 ];

Line range hint 1-211: Well-structured test class with good coverage

The test class demonstrates good testing practices:

  • Clear test method names following the pattern Method_Scenario_ExpectedResult
  • Consistent Arrange-Act-Assert pattern
  • Comprehensive coverage of edge cases (null, empty string, numeric values, etc.)

Consider adding a few more test cases:

  1. Very large tables (performance test)
  2. Unicode character handling
  3. Negative numbers alignment
src/Digdir.Domain.Dialogporten.Infrastructure/UnitOfWork.cs (2)

61-61: LGTM! Clean refactoring to expression-bodied syntax.

The conversion to an expression-bodied member improves code conciseness while maintaining the same behavior.


Line range hint 7-13: Consider externalizing retry policy configuration.

The current implementation uses a hardcoded retry policy with constant backoff (25 retries * 200ms). Consider:

  1. Moving retry configuration to application settings to support different environments
  2. Using exponential backoff instead of constant backoff for better handling of database contention
  3. Reviewing if 25 retries (5 seconds total) is appropriate for your use case

Example configuration pattern:

public class RetryPolicyOptions
{
    public int MaxRetries { get; set; }
    public TimeSpan InitialDelay { get; set; }
    public BackoffType BackoffStrategy { get; set; }
}

// In constructor:
public UnitOfWork(
    DialogDbContext dialogDbContext,
    IOptions<RetryPolicyOptions> retryOptions,
    ...)
{
    var policy = retryOptions.Value.BackoffStrategy switch
    {
        BackoffType.Constant => Policy
            .Handle<DbUpdateConcurrencyException>()
            .WaitAndRetryAsync(
                retryOptions.Value.MaxRetries,
                _ => retryOptions.Value.InitialDelay,
                onRetryAsync: FetchCurrentRevision),
        BackoffType.Exponential => Policy
            .Handle<DbUpdateConcurrencyException>()
            .WaitAndRetryAsync(
                Backoff.ExponentialBackoff(
                    retryOptions.Value.InitialDelay,
                    retryOptions.Value.MaxRetries),
                onRetryAsync: FetchCurrentRevision),
        _ => throw new ArgumentException("Invalid backoff strategy")
    };
}
src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/AltinnAuthorizationClient.cs (1)

Line range hint 91-98: LGTM! Consider collection optimization.

The array syntax modernization is a good improvement. For even better performance, consider declaring the arrays as static readonly if these are frequently used with the same values:

+ private static readonly string[] SingleItemArray = new[] { string.Empty };

This would help avoid array allocations for common single-item cases.

src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs (1)

295-295: Consider making process URI generation more domain-specific.

The refactoring to expression-bodied syntax improves code conciseness. However, the current implementation generates generic URLs, which may not accurately represent real-world process URIs in your domain.

Consider using a more domain-specific format:

-    public static string GenerateFakeProcessUri() => new Faker().Internet.UrlWithPath(Uri.UriSchemeHttps);
+    public static string GenerateFakeProcessUri() => $"urn:altinn:process:{new Faker().Random.AlphaNumeric(10)}";
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d289e10 and 7b28f54.

📒 Files selected for processing (51)
  • src/Digdir.Domain.Dialogporten.Application/Common/Behaviours/DomainContextBehaviour.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Common/Extensions/OptionExtensions/FluentValidationOptions.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogSeenLogs/Queries/Search/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Search/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Search/SearchDialogQuery.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Get/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Search/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Search/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.ChangeDataCapture/ICdcSink.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.ChangeDataCapture/appsettings.Development.json (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Common/EventPublisher/IDomainEvent.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Common/Exceptions/DomainException.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/DialogEndUserContexts/Entities/DialogEndUserContext.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Entities/DialogEntity.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogCreatedDomainEvent.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogSeenDomainEvent.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogUpdatedDomainEvent.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Localizations/LocalizationSet.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/Common/Authorization/AllowAnonymousHandler.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/Common/Constants.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/AltinnAuthorizationClient.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/DialogDetailsAuthorizationRequest.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/DialogEntityExtensions.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/LocalDevelopmentAltinnAuthorization.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/ResourceRegistryClient.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/ValueConverters/DateTimeOffsetConverter.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Infrastructure/UnitOfWork.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Janitor/Program.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs (1 hunks)
  • src/Digdir.Library.Entity.Abstractions/Features/Aggregate/IAggregateChangedHandler.cs (1 hunks)
  • src/Digdir.Library.Entity.Abstractions/Features/Identifiable/IdentifiableExtensions.cs (1 hunks)
  • src/Digdir.Library.Entity.Abstractions/Features/Lookup/AbstractLookupEntity.cs (1 hunks)
  • src/Digdir.Library.Entity.Abstractions/Features/Lookup/ILookupEntity.cs (2 hunks)
  • src/Digdir.Library.Entity.Abstractions/Features/SoftDeletable/ISoftDeletableEntity.cs (1 hunks)
  • src/Digdir.Library.Entity.Abstractions/IJoinEntity.cs (1 hunks)
  • src/Digdir.Library.Entity.EntityFrameworkCore/EntityLibraryEfCoreExtensions.cs (2 hunks)
  • src/Digdir.Library.Entity.EntityFrameworkCore/Features/Aggregate/AggregateExtensions.cs (4 hunks)
  • src/Digdir.Library.Entity.EntityFrameworkCore/Features/Lookup/LookupEntityExtensions.cs (1 hunks)
  • src/Digdir.Library.Entity.EntityFrameworkCore/Features/SoftDeletable/SoftDeletableExtensions.cs (6 hunks)
  • src/Digdir.Tool.Dialogporten.Benchmarks/TokenGenerationBenchmark.cs (2 hunks)
  • src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs (1 hunks)
  • src/Digdir.Tool.Dialogporten.GenerateFakeData/README.md (2 hunks)
  • src/Digdir.Tool.Dialogporten.SlackNotifier/Common/Extensions.cs (1 hunks)
  • tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Common/IHierarchyTestNodeBuilder.cs (1 hunks)
  • tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/Common/Utils/ApplicationEventHandlerUtilsTests.cs (1 hunks)
  • tests/Digdir.Tool.Dialogporten.SlackNotifier.Tests/AsciiTableFormatterTests.cs (9 hunks)
💤 Files with no reviewable changes (11)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogSeenLogs/Queries/Search/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Get/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogTransmissions/Queries/Search/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Get/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogSeenLogs/Queries/Search/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Get/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogTransmissions/Queries/Search/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Entities/DialogEntity.cs
  • src/Digdir.Domain.Dialogporten.GraphQL/Common/Constants.cs
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/DialogById/MappingProfile.cs
✅ Files skipped from review due to trivial changes (30)
  • src/Digdir.Domain.Dialogporten.Application/Common/Behaviours/DomainContextBehaviour.cs
  • src/Digdir.Domain.Dialogporten.Application/Common/Extensions/OptionExtensions/FluentValidationOptions.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Search/SearchDialogQuery.cs
  • src/Digdir.Domain.Dialogporten.ChangeDataCapture/ICdcSink.cs
  • src/Digdir.Domain.Dialogporten.ChangeDataCapture/appsettings.Development.json
  • src/Digdir.Domain.Dialogporten.Domain/Common/EventPublisher/IDomainEvent.cs
  • src/Digdir.Domain.Dialogporten.Domain/Common/Exceptions/DomainException.cs
  • src/Digdir.Domain.Dialogporten.Domain/DialogEndUserContexts/Entities/DialogEndUserContext.cs
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogCreatedDomainEvent.cs
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogSeenDomainEvent.cs
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogUpdatedDomainEvent.cs
  • src/Digdir.Domain.Dialogporten.Domain/Localizations/LocalizationSet.cs
  • src/Digdir.Domain.Dialogporten.GraphQL/Common/Authorization/AllowAnonymousHandler.cs
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/DialogDetailsAuthorizationRequest.cs
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/DialogEntityExtensions.cs
  • src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/ResourceRegistry/ResourceRegistryClient.cs
  • src/Digdir.Domain.Dialogporten.Infrastructure/InfrastructureSettings.cs
  • src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/ValueConverters/DateTimeOffsetConverter.cs
  • src/Digdir.Domain.Dialogporten.Janitor/Program.cs
  • src/Digdir.Library.Entity.Abstractions/Features/Lookup/AbstractLookupEntity.cs
  • src/Digdir.Library.Entity.Abstractions/Features/Lookup/ILookupEntity.cs
  • src/Digdir.Library.Entity.Abstractions/Features/SoftDeletable/ISoftDeletableEntity.cs
  • src/Digdir.Library.Entity.Abstractions/IJoinEntity.cs
  • src/Digdir.Library.Entity.EntityFrameworkCore/EntityLibraryEfCoreExtensions.cs
  • src/Digdir.Library.Entity.EntityFrameworkCore/Features/Aggregate/AggregateExtensions.cs
  • src/Digdir.Library.Entity.EntityFrameworkCore/Features/Lookup/LookupEntityExtensions.cs
  • src/Digdir.Tool.Dialogporten.Benchmarks/TokenGenerationBenchmark.cs
  • src/Digdir.Tool.Dialogporten.GenerateFakeData/README.md
  • src/Digdir.Tool.Dialogporten.SlackNotifier/Common/Extensions.cs
  • tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/Common/Utils/ApplicationEventHandlerUtilsTests.cs
🔇 Additional comments (14)
src/Digdir.Library.Entity.Abstractions/Features/Identifiable/IdentifiableExtensions.cs (1)

37-41: LGTM! Well-documented implementation.

The conversion to an expression-bodied member improves code conciseness while maintaining readability. The comment explaining the endianness behavior is particularly valuable for preventing potential bugs and helping future maintainers understand the implementation details.

tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Common/IHierarchyTestNodeBuilder.cs (2)

24-24: LGTM! Clean conversion to expression-bodied member.

The conversion to expression-bodied syntax improves code conciseness while maintaining readability.


27-27: LGTM! Verify test coverage for cyclic scenarios.

The conversion to expression-bodied syntax is clean. Since this method creates cyclic hierarchies, let's ensure we have adequate test coverage for various cyclic scenarios.

src/Digdir.Domain.Dialogporten.WebApi/OpenApiDocumentExtensions.cs (1)

Line range hint 65-65: Verify C# version compatibility for collection expressions

The code uses C# collection expressions ([...]), which requires C# 12.0. Ensure this is compatible with your project's target framework and build environment.

✅ Verification successful

C# version compatibility confirmed

The project targets .NET 8.0, which supports C# 12.0 collection expressions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check .csproj files for language version and framework
fd -e csproj -x cat {} \; | grep -E "LangVersion|TargetFramework"

Length of output: 270

tests/Digdir.Tool.Dialogporten.SlackNotifier.Tests/AsciiTableFormatterTests.cs (3)

11-15: Great use of modern C# features!

The changes improve code quality by:

  • Using collection expressions for more concise list initialization
  • Making constants explicit with const keyword
  • Using extension method syntax for better readability

Also applies to: 17-17, 20-20, 23-23


41-45: LGTM!

Changes are consistent with the previous method.

Also applies to: 47-47, 50-50, 53-53


Line range hint 99-211: LGTM! Consistent improvements throughout the test class

The remaining changes follow the same pattern of improvements:

  • Consistent use of collection expressions
  • Proper constant declarations
  • Clear extension method usage
src/Digdir.Library.Entity.EntityFrameworkCore/Features/SoftDeletable/SoftDeletableExtensions.cs (6)

55-55: LGTM! Documentation update improves consistency.

The hyphenation in "soft-delete" improves terminology consistency across the codebase.


64-66: LGTM! Good defensive programming practice.

The added fallback behavior ensures the entity is properly marked as deleted, even if the SoftDelete() implementation is incomplete.


76-76: LGTM! Documentation maintains consistency.

The hyphenation in "soft-delete" maintains the established terminology pattern.


98-98: LGTM! Documentation updates maintain consistency.

The hyphenation in comments maintains consistent terminology throughout the codebase.

Also applies to: 105-105, 112-112


137-138: LGTM! Clear and descriptive comments.

The comments effectively explain the validation logic for soft-deleted entities.


90-92: Consider compiler compatibility when using collection expressions.

The code uses C# 12's collection expression syntax [modelBuilder]. Ensure your build environment and deployment targets support C# 12 features.

✅ Verification successful

C# 12 collection expressions are supported by the target framework.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check target framework version in project file
rg -l "TargetFramework" | xargs cat

Length of output: 6527

src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/AltinnAuthorizationClient.cs (1)

84-87: Temporary caching disable looks good, but monitor performance.

The temporary disabling of caching with a clear reference to issue #1226 is a good interim solution. However, since this could impact performance, consider:

  1. Adding performance monitoring/logging for this endpoint
  2. Setting up alerts for significant response time increases

Let's verify if this caching issue affects other parts of the codebase:

✅ Verification successful

Caching disable is isolated to AltinnAuthorizationClient.cs; no additional impacts found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other potential uses of _partiesCache that might be affected
rg "_partiesCache" -A 3 -B 3

# Search for related caching patterns that might need similar treatment
ast-grep --pattern 'await $_Cache.GetOrSetAsync($_, async token => await $_, token: $_)'

Length of output: 3494

{
_transaction ??= await _dialogDbContext.Database.BeginTransactionAsync(cancellationToken);
}
=> _transaction ??= await _dialogDbContext.Database.BeginTransactionAsync(cancellationToken);
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Potential Transaction Leaks Identified in IOutboxReaderRepository.cs

  • BeginTransactionAsync is used outside of UnitOfWork.cs, which may lead to transaction leaks.
🔗 Analysis chain

Verify transaction management across the codebase.

While the transaction management in this class looks solid, let's verify proper usage across the codebase to prevent transaction leaks.

Also applies to: 142-157

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for proper transaction management and potential bypasses

# Check for direct DbContext usage that might bypass UnitOfWork
echo "Checking for direct DbContext usage..."
rg "DialogDbContext" --type cs -C 3 | grep -v "UnitOfWork.cs"

# Check for proper disposal of UnitOfWork
echo "Checking UnitOfWork disposal patterns..."
ast-grep --pattern 'using var unitOfWork = $_;'
ast-grep --pattern 'await using var unitOfWork = $_;'

# Check for potential transaction leaks
echo "Checking for potential transaction leaks..."
rg "BeginTransactionAsync" --type cs -C 5

Length of output: 96436

Comment on lines +13 to 14
private static readonly MethodInfo OpenGenericInternalMethodInfo = typeof(SoftDeletableExtensions)
.GetMethod(nameof(EnableSoftDeletableQueryFilter_Internal), BindingFlags.NonPublic | BindingFlags.Static)!;
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

Revert field name to follow C# naming conventions.

The field name change from _openGenericInternalMethodInfo to OpenGenericInternalMethodInfo breaks C# naming conventions where private fields should be prefixed with an underscore. This affects code consistency and readability.

-    private static readonly MethodInfo OpenGenericInternalMethodInfo = typeof(SoftDeletableExtensions)
+    private static readonly MethodInfo _openGenericInternalMethodInfo = typeof(SoftDeletableExtensions)
📝 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
private static readonly MethodInfo OpenGenericInternalMethodInfo = typeof(SoftDeletableExtensions)
.GetMethod(nameof(EnableSoftDeletableQueryFilter_Internal), BindingFlags.NonPublic | BindingFlags.Static)!;
private static readonly MethodInfo _openGenericInternalMethodInfo = typeof(SoftDeletableExtensions)
.GetMethod(nameof(EnableSoftDeletableQueryFilter_Internal), BindingFlags.NonPublic | BindingFlags.Static)!;

@oskogstad oskogstad merged commit f84380b into main Nov 13, 2024
25 checks passed
@oskogstad oskogstad deleted the chore/november-cleaning branch November 13, 2024 09:34
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