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

Code scanning fix patches #638

Merged
merged 5 commits into from
Jan 28, 2025
Merged

Code scanning fix patches #638

merged 5 commits into from
Jan 28, 2025

Conversation

64J0
Copy link
Member

@64J0 64J0 commented Jan 16, 2025

Description

Fix the following code scan warnings:

Before this PR (29 open items):

image

After this PR (25 open items):

image

How to test

Check CI.

@64J0 64J0 self-assigned this Jan 16, 2025
@@ -44,7 +44,7 @@ let mustAcceptAny (mimeTypes: string list) (optionalErrorHandler: OptionalErrorH
)

match Option.ofObj (headers.Accept :> _ seq) with
| Some xs when Seq.map (_.ToString()) xs |> Seq.exists (fun x -> Seq.contains x mimeTypes) -> next ctx
| Some xs when Seq.map (_.ToString()) xs |> Seq.exists (fun x -> List.contains x mimeTypes) -> next ctx
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, you can probably move the ToString inside the Seq.exists.
And I wonder if Sets should be used here. The order of mimeTypes doesn't matter here.

@@ -55,14 +55,17 @@ module ResponseCaching =
| Public duration -> tHeaders.CacheControl <- cacheHeader true duration
| Private duration -> tHeaders.CacheControl <- cacheHeader false duration

if vary.IsSome then
headers.[HeaderNames.Vary] <- StringValues [| vary.Value |]
match vary with
Copy link
Contributor

Choose a reason for hiding this comment

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

Option.iter maybe?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, using Option.iter improves readability (my POV), thanks for the suggestion!

@64J0 64J0 force-pushed the code-scanning-patches branch from 992f916 to ec66153 Compare January 27, 2025 23:33
@64J0 64J0 requested review from nojaf, TheAngryByrd and mrtz-j January 28, 2025 01:20
@64J0 64J0 marked this pull request as ready for review January 28, 2025 01:20
@64J0 64J0 merged commit 0376ef4 into master Jan 28, 2025
6 checks passed
@64J0 64J0 deleted the code-scanning-patches branch January 28, 2025 20:32
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.

3 participants