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

Hook up fantomas for F# formatting #3039

Merged
merged 12 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ jobs:
- store_artifacts: { path: rundir }
- store_test_results: { path: rundir/test_results }


check-formatting:
executor: in-container
steps:
- checkout
- run: scripts/format check

build-stroller:
executor: in-rust-container
Expand Down Expand Up @@ -420,6 +424,7 @@ workflows:
build-and-deploy:
jobs:
# initial builds & tests
- check-formatting
- build-postgres-honeytail
- validate-honeycomb-config
- build-backend
Expand Down
40 changes: 20 additions & 20 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ max_line_length=80
[*.fs]
indent_size=2
max_line_length=85
fsharp_semicolon_at_end_of_line=false
fsharp_space_before_parameter=true
fsharp_space_before_lowercase_invocation=true
fsharp_space_before_uppercase_invocation=false
fsharp_space_before_class_constructor=false
fsharp_space_before_member=false
fsharp_space_before_colon=true
fsharp_space_after_comma=true
fsharp_space_before_semicolon=false
fsharp_space_after_semicolon=true
fsharp_align_function_signature_to_indentation=false
fsharp_alternative_long_member_definitions=false
fsharp_array_or_list_multiline_formatter=character_width
fsharp_indent_on_try_with=false
fsharp_space_around_delimiter=true
fsharp_keep_if_then_in_same_line=false
fsharp_max_array_or_list_size=3
fsharp_max_array_or_list_width=85
fsharp_max_dot_get_expression_width=85
fsharp_max_elmish_width=85
fsharp_max_function_binding_width=85
fsharp_max_if_then_else_short_width=80
fsharp_max_infix_operator_expression=80
fsharp_max_record_width=85
fsharp_max_array_or_list_width=85
fsharp_max_array_or_list_size=3
fsharp_array_or_list_multiline_formatter=character_width
fsharp_max_value_binding_width=85
fsharp_max_function_binding_width=85
fsharp_max_dot_get_expression_width=85
fsharp_multiline_block_brackets_on_same_column=false
fsharp_newline_between_type_definition_and_members=true
fsharp_keep_if_then_in_same_line=false
fsharp_max_elmish_width=85
fsharp_semicolon_at_end_of_line=false
fsharp_single_argument_web_mode=false
fsharp_align_function_signature_to_indentation=false
fsharp_alternative_long_member_definitions=false
fsharp_space_after_comma=true
fsharp_space_after_semicolon=true
fsharp_space_around_delimiter=true
fsharp_space_before_class_constructor=false
fsharp_space_before_colon=true
fsharp_space_before_lowercase_invocation=true
fsharp_space_before_member=false
fsharp_space_before_parameter=true
fsharp_space_before_semicolon=false
fsharp_space_before_uppercase_invocation=false
fsharp_strict_mode=false
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ ENV LC_ALL en_US.UTF-8
############################
USER root

RUN npm install -g prettier@2.2.1

# Esy is currently a nightmare. Upgrading to esy 6.6 is stalled because:
# - esy 6.6 copies from ~/.esy to _esy, and in our container, that copy is
# cross-volume, so it fails with an EXDEV error.
Expand Down Expand Up @@ -356,6 +358,15 @@ ENV TERM=xterm-256color
############################
USER dark

RUN sudo apt update && sudo apt install -y lldb htop
RUN dotnet tool install -g dotnet-sos
RUN echo "plugin load /home/dark/.dotnet/tools/.store/dotnet-sos/5.0.160202/dotnet-sos/5.0.160202/tools/netcoreapp2.1/any/linux-x64/libsosplugin.so" > ~/.lldbinit

# formatting
ENV PATH "$PATH:/home/dark/bin"
RUN dotnet tool install fantomas-tool --version 4.4.0 --tool-path /home/dark/bin


########################
# Install Rust toolchain
# This is in a separate container to save time in CI
Expand Down Expand Up @@ -384,7 +395,3 @@ RUN cargo install cargo-cache --no-default-features --features ci-autoclean
ENV CARGO_HOME=/home/dark/.cargo

USER dark

RUN sudo apt update && sudo apt install -y lldb htop
RUN dotnet tool install -g dotnet-sos
RUN echo "plugin load /home/dark/.dotnet/tools/.store/dotnet-sos/5.0.160202/dotnet-sos/5.0.160202/tools/netcoreapp2.1/any/linux-x64/libsosplugin.so" > ~/.lldbinit
2 changes: 1 addition & 1 deletion fsharp-backend/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"commands": ["paket"]
}
}
}
}
8 changes: 7 additions & 1 deletion fsharp-backend/src/LibBackend/Authorization.fs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ let specialCasePermission
(username : UserName.T)
(ownerName : OwnerName.T)
: Option<Permission> =
if List.any ((=) (ownerName, username)) specialCases then
if List.any
((=)
(
ownerName,
username
))
specialCases then
pbiggar marked this conversation as resolved.
Show resolved Hide resolved
Some ReadWrite
else
None
Expand Down
66 changes: 25 additions & 41 deletions fsharp-backend/src/LibBackend/StdLib/LibCrypto.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,80 +78,64 @@ let fns : List<BuiltInFn> =
previewable = Impure
deprecated = NotDeprecated }
{ name = fn "Crypto" "sha256" 0
parameters = [Param.make "data" TBytes ""]
parameters = [ Param.make "data" TBytes "" ]
returnType = TBytes
description = "Computes the SHA-256 digest of the given `data`."
fn =
(function
| _, [DBytes data] ->
SHA256.HashData (ReadOnlySpan data)
|> DBytes
|> Value
| _ -> incorrectArgs ())
(function
| _, [ DBytes data ] -> SHA256.HashData(ReadOnlySpan data) |> DBytes |> Value
| _ -> incorrectArgs ())
sqlSpec = NotYetImplementedTODO
previewable = Impure
deprecated = NotDeprecated }
{ name = fn "Crypto" "sha384" 0
parameters = [Param.make "data" TBytes ""]
parameters = [ Param.make "data" TBytes "" ]
returnType = TBytes
description = "Computes the SHA-384 digest of the given `data`."
fn =
(function
| _, [DBytes data] ->
SHA384.HashData (ReadOnlySpan data)
|> DBytes
|> Value
| _ -> incorrectArgs ())
(function
| _, [ DBytes data ] -> SHA384.HashData(ReadOnlySpan data) |> DBytes |> Value
| _ -> incorrectArgs ())
sqlSpec = NotYetImplementedTODO
previewable = Impure
deprecated = NotDeprecated }
{ name = fn "Crypto" "md5" 0
parameters = [Param.make "data" TBytes ""]
parameters = [ Param.make "data" TBytes "" ]
returnType = TBytes
description =
"Computes the md5 digest of the given `data`. NOTE: There are multiple security problems with md5, see https://en.wikipedia.org/wiki/MD5#Security"
fn =
(function
| _, [DBytes data] ->
MD5.HashData (ReadOnlySpan data)
|> DBytes
|> Value
| _ -> incorrectArgs ())
(function
| _, [ DBytes data ] -> MD5.HashData(ReadOnlySpan data) |> DBytes |> Value
| _ -> incorrectArgs ())
sqlSpec = NotYetImplementedTODO
previewable = Impure
deprecated = NotDeprecated }
{ name = fn "Crypto" "sha256hmac" 0
parameters = [Param.make "key" TBytes ""; Param.make "data" TBytes ""]
parameters = [ Param.make "key" TBytes ""; Param.make "data" TBytes "" ]
returnType = TBytes
description =
"Computes the SHA-256 HMAC (hash-based message authentication code) digest of the given `key` and `data`."
fn =
(function
| _, [DBytes key; DBytes data] ->
let hmac = new HMACSHA256(key)
data
|> hmac.ComputeHash
|> DBytes
|> Value
| _ -> incorrectArgs ())
(function
| _, [ DBytes key; DBytes data ] ->
let hmac = new HMACSHA256(key)
data |> hmac.ComputeHash |> DBytes |> Value
| _ -> incorrectArgs ())
sqlSpec = NotYetImplementedTODO
previewable = Impure
deprecated = NotDeprecated }
{ name = fn "Crypto" "sha1hmac" 0
parameters = [Param.make "key" TBytes ""; Param.make "data" TBytes ""]
parameters = [ Param.make "key" TBytes ""; Param.make "data" TBytes "" ]
returnType = TBytes
description =
"Computes the SHA1-HMAC (hash-based message authentication code) digest of the given `key` and `data`."
fn =
(function
| _, [DBytes key; DBytes data] ->
let hmac = new HMACSHA1(key)
data
|> hmac.ComputeHash
|> DBytes
|> Value
| _ -> incorrectArgs ())
(function
| _, [ DBytes key; DBytes data ] ->
let hmac = new HMACSHA1(key)
data |> hmac.ComputeHash |> DBytes |> Value
| _ -> incorrectArgs ())
sqlSpec = NotYetImplementedTODO
previewable = Impure
deprecated = NotDeprecated }
]
deprecated = NotDeprecated } ]
Loading