-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Fix issues reported by static analysis #1357
Conversation
WalkthroughThe recent updates across various Dockerfiles enhance readability and maintainability while preserving core functionality. Key improvements include restructuring package installations, refining build flag formatting, and consolidating commands for optimization. These changes result in a cleaner codebase, making navigation and future modifications easier for developers. Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (4)
charts/plgd-hub/templates/certs/default/ca-issuer.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/certs/default/root-ca.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/certs/storage/scylla-crt.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/mongodb-standby-tool/config.yaml
is excluded by!**/*.yaml
Files selected for processing (19)
- Dockerfile.test (2 hunks)
- bundle/Dockerfile (3 hunks)
- grpc-gateway/client/maintenance.go (1 hunks)
- http-gateway/Dockerfile (2 hunks)
- http-gateway/Dockerfile.www (1 hunks)
- m2m-oauth-server/store/mongodb/tokens_test.go (1 hunks)
- pkg/net/grpc/authFromOutgoingMD.go (1 hunks)
- pkg/security/certManager/general/certManager_test.go (1 hunks)
- resource-aggregate/cqrs/eventstore/cqldb/load.go (2 hunks)
- resource-aggregate/events/deviceMetadataSnapshotTaken.go (2 hunks)
- resource-aggregate/events/resourceLinksSnapshotTaken.go (2 hunks)
- resource-aggregate/events/resourceStateSnapshotTaken.go (3 hunks)
- test/cloud-server/Dockerfile (1 hunks)
- test/security/jwk.go (2 hunks)
- tools/cert-tool/Dockerfile (2 hunks)
- tools/docker/Dockerfile.in (2 hunks)
- tools/grpc-reflection/Dockerfile (2 hunks)
- tools/mongodb/admin-tool/Dockerfile (2 hunks)
- tools/mongodb/standby-tool/Dockerfile (2 hunks)
Files skipped from review due to trivial changes (9)
- http-gateway/Dockerfile
- http-gateway/Dockerfile.www
- pkg/security/certManager/general/certManager_test.go
- test/cloud-server/Dockerfile
- tools/cert-tool/Dockerfile
- tools/docker/Dockerfile.in
- tools/grpc-reflection/Dockerfile
- tools/mongodb/admin-tool/Dockerfile
- tools/mongodb/standby-tool/Dockerfile
Additional comments not posted (21)
Dockerfile.test (2)
3-4
: Reformatting improves readability.The restructuring of the
apt-get install
command into multiple lines enhances readability and maintainability.
7-7
: Verify the impact ofWORKDIR /
.The addition of
WORKDIR /
changes the context for subsequent commands. Ensure that this change does not affect operations that rely on the current directory.test/security/jwk.go (1)
73-75
: Improved performance and simplicity.Switching from
io.WriteString
tow.Write
enhances performance by avoiding unnecessary string conversion and simplifies the code.pkg/net/grpc/authFromOutgoingMD.go (2)
17-19
: Centralized error handling improves maintainability.The introduction of
errUnauthenticated
centralizes error creation, reducing redundancy and enhancing readability and maintainability.
26-26
: Refactored error handling enhances clarity.Refactoring error handling to use
errUnauthenticated
improves the clarity and consistency of the code.Also applies to: 33-33
grpc-gateway/client/maintenance.go (1)
86-86
: Improved error message formatting.The addition of a format specifier ("%s") in the error message enhances clarity and consistency in error reporting.
resource-aggregate/cqrs/eventstore/cqldb/load.go (3)
Line range hint
139-160
:
Modularized aggregate ID filtering.The introduction of
addAggregateIDsToFilter
improves modularity and readability by separating the logic for handling aggregate IDs.
162-171
: Modularized timestamp filtering.The new
addTimestampToFilter
function enhances modularity by isolating the timestamp handling logic, making the code easier to maintain.
173-179
: Refactored filter construction for snapshots.The use of helper functions in
snapshotQueriesToFilter
streamlines the logic and improves maintainability by delegating specific responsibilities.m2m-oauth-server/store/mongodb/tokens_test.go (1)
239-239
: Simplified test assertion.Replacing
require.Greater
withrequire.Positive
clarifies the intent of the test by directly asserting that the timestamp is positive.resource-aggregate/events/resourceLinksSnapshotTaken.go (2)
173-195
: Centralize event handling logic inhandleByEvent
.The
handleByEvent
method centralizes the event handling logic, improving code organization and maintainability. The switch statement effectively manages different event types by unmarshalling and invoking the corresponding handler methods.
- Error Handling: The error handling for unmarshalling is consistent with the existing code style, returning internal status errors.
- Maintainability: This refactoring enhances readability and makes future extensions easier.
Ensure that all potential event types are covered and that any new event types are added here in the future.
Line range hint
196-207
:
RefactorHandle
method to usehandleByEvent
.The
Handle
method now delegates event-specific logic to thehandleByEvent
method. This refactoring separates concerns, making the code cleaner and more modular.
- Error Handling: The check for an empty event type is appropriately placed before invoking
handleByEvent
, ensuring robustness.Verify that all event types processed in
handleByEvent
are correctly handled in this method.bundle/Dockerfile (4)
3-3
: Reorder package installations for clarity.The reordering of the
apk add
command improves readability but does not affect functionality. Ensure that the order aligns with any dependencies that might exist between packages.
24-29
: Improve build flag formatting for readability.Splitting the
-ldflags
across multiple lines enhances readability and maintainability. This change makes it easier to understand and modify the build process. Ensure that all flags are correctly specified and that there are no syntax errors.Also applies to: 37-42, 50-55, 63-68, 76-81, 89-94, 102-107, 115-120, 128-133, 141-146, 154-159, 167-172, 180-185, 193-198
213-219
: Consolidate commands to reduce image layers.Consolidating multiple
RUN
commands into a single command using&&
reduces the number of layers in the Docker image, optimizing the build process. Ensure that all commands execute correctly in sequence.
228-232
: Streamline package installation in the base image.The changes to the
apt-get install
command enhance readability and maintainability. Ensure that the list of packages and the installation process remain correct and efficient.resource-aggregate/events/deviceMetadataSnapshotTaken.go (1)
161-163
: Relocate event type validation toHandle
method.The relocation of the event type validation to the
Handle
method ensures that events with undefined types are not processed. This change enhances the robustness of the error handling process.
- Error Handling: The check for an empty event type is correctly placed before invoking
handleByEvent
.Verify that this change does not affect the handling of valid events.
resource-aggregate/events/resourceStateSnapshotTaken.go (4)
115-118
: Interface Definition Looks Good.The
pendingEvent
interface is well-defined and ensures that types implementing it can be used with the generic functioncheckForDuplicityCorrelationID
.
120-130
: Generic Function Implementation Looks Good.The
checkForDuplicityCorrelationID
function effectively uses generics to reduce code duplication and enhance modularity while maintaining the original functionality.
132-143
: Refactored Method Looks Good.The refactoring of
checkForDuplicityCorrelationID
simplifies the method by removing repetitive code and using the generic function. Error handling is appropriately retained.
410-412
: Event Type Check Placement Looks Good.Moving the check for an empty event type string within the loop improves clarity by ensuring validation before processing.
72e6d5a
to
d4e70a7
Compare
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
resource-aggregate/cqrs/eventstore/cqldb/load.go (1)
Line range hint
139-160
: Optimize string concatenation withstrings.Builder
.Using
strings.Builder
foraggrs
can improve performance by reducing memory allocations during string concatenation.func addAggregateIDsToFilter(filter *strings.Builder, queries []eventstore.SnapshotQuery) { var aggrs strings.Builder for _, q := range queries { if q.AggregateID != "" && q.AggregateID != uuid.Nil.String() { if aggrs.Len() > 0 { aggrs.WriteString(",") } aggrs.WriteString(q.AggregateID) } } if aggrs.Len() > 0 { if filter.Len() > 0 { filter.WriteString(" and ") } filter.WriteString(idKey) filter.WriteString(" in (") filter.WriteString(aggrs.String()) filter.WriteString(")") } }
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (4)
charts/plgd-hub/templates/certs/default/ca-issuer.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/certs/default/root-ca.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/certs/storage/scylla-crt.yaml
is excluded by!**/*.yaml
charts/plgd-hub/templates/mongodb-standby-tool/config.yaml
is excluded by!**/*.yaml
Files selected for processing (19)
- Dockerfile.test (2 hunks)
- bundle/Dockerfile (3 hunks)
- grpc-gateway/client/maintenance.go (1 hunks)
- http-gateway/Dockerfile (2 hunks)
- http-gateway/Dockerfile.www (1 hunks)
- m2m-oauth-server/store/mongodb/tokens_test.go (1 hunks)
- pkg/net/grpc/authFromOutgoingMD.go (1 hunks)
- pkg/security/certManager/general/certManager_test.go (1 hunks)
- resource-aggregate/cqrs/eventstore/cqldb/load.go (2 hunks)
- resource-aggregate/events/deviceMetadataSnapshotTaken.go (2 hunks)
- resource-aggregate/events/resourceLinksSnapshotTaken.go (2 hunks)
- resource-aggregate/events/resourceStateSnapshotTaken.go (3 hunks)
- test/cloud-server/Dockerfile (1 hunks)
- test/security/jwk.go (2 hunks)
- tools/cert-tool/Dockerfile (2 hunks)
- tools/docker/Dockerfile.in (2 hunks)
- tools/grpc-reflection/Dockerfile (2 hunks)
- tools/mongodb/admin-tool/Dockerfile (2 hunks)
- tools/mongodb/standby-tool/Dockerfile (2 hunks)
Files skipped from review due to trivial changes (6)
- http-gateway/Dockerfile
- http-gateway/Dockerfile.www
- test/cloud-server/Dockerfile
- tools/cert-tool/Dockerfile
- tools/mongodb/admin-tool/Dockerfile
- tools/mongodb/standby-tool/Dockerfile
Files skipped from review as they are similar to previous changes (11)
- Dockerfile.test
- bundle/Dockerfile
- grpc-gateway/client/maintenance.go
- m2m-oauth-server/store/mongodb/tokens_test.go
- pkg/net/grpc/authFromOutgoingMD.go
- resource-aggregate/events/deviceMetadataSnapshotTaken.go
- resource-aggregate/events/resourceLinksSnapshotTaken.go
- resource-aggregate/events/resourceStateSnapshotTaken.go
- test/security/jwk.go
- tools/docker/Dockerfile.in
- tools/grpc-reflection/Dockerfile
Additional context used
golangci-lint
pkg/security/certManager/general/certManager_test.go
181-181: SA1019: pool.Subjects has been deprecated since Go 1.18: if s was returned by [SystemCertPool], Subjects will not include the system roots.
(staticcheck)
185-185: SA1019: pool.Subjects has been deprecated since Go 1.18: if s was returned by [SystemCertPool], Subjects will not include the system roots.
(staticcheck)
192-192: SA1019: pool.Subjects has been deprecated since Go 1.18: if s was returned by [SystemCertPool], Subjects will not include the system roots.
(staticcheck)
Additional comments not posted (4)
resource-aggregate/cqrs/eventstore/cqldb/load.go (2)
174-180
: LGTM!The function is well-structured, using helper functions effectively to construct the filter string.
162-172
: Verify the use ofALLOW FILTERING
.The use of
ALLOW FILTERING
can impact query performance and correctness. Ensure it is necessary and used appropriately.pkg/security/certManager/general/certManager_test.go (2)
185-185
: Replace deprecatedpool.Subjects
usage.
pool.Subjects
has been deprecated. Consider usingpool.VerifyPeerCertificate
or another appropriate method to check certificate subjects.Tools
golangci-lint
185-185: SA1019: pool.Subjects has been deprecated since Go 1.18: if s was returned by [SystemCertPool], Subjects will not include the system roots.
(staticcheck)
192-192
: Replace deprecatedpool.Subjects
usage.
pool.Subjects
has been deprecated. Consider usingpool.VerifyPeerCertificate
or another appropriate method to check certificate subjects.Tools
golangci-lint
192-192: SA1019: pool.Subjects has been deprecated since Go 1.18: if s was returned by [SystemCertPool], Subjects will not include the system roots.
(staticcheck)
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- Dockerfile.test (2 hunks)
- bundle/Dockerfile (3 hunks)
- test/cloud-server/Dockerfile (2 hunks)
Files skipped from review due to trivial changes (1)
- test/cloud-server/Dockerfile
Files skipped from review as they are similar to previous changes (2)
- Dockerfile.test
- bundle/Dockerfile
6e98277
to
e360303
Compare
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- Dockerfile.test (2 hunks)
- bundle/Dockerfile (3 hunks)
- test/cloud-server/Dockerfile (2 hunks)
Files skipped from review due to trivial changes (1)
- test/cloud-server/Dockerfile
Files skipped from review as they are similar to previous changes (2)
- Dockerfile.test
- bundle/Dockerfile
Quality Gate passedIssues Measures |
No description provided.