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

Consider all function applications as short branch. #1784

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
60 changes: 60 additions & 0 deletions src/Fantomas.Tests/KeepIndentInBranchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1770,3 +1770,63 @@ let updateModuleInImpl (ast: ParsedInput) (mdl: SynModuleOrNamespace) : ParsedIn
)
|> ParsedInput.ImplFile
"""

[<Test>]
let ``short function application in if branch`` () =
formatSourceString
false
"""
let private parseModel (modelSrc: string) : Result<MyReturnType, string list> =
if not (File.Exists(modelSrc)) then
Error [ sprintf "Provided modelSrc \"%s\" does not exist" modelSrc ]
else
let graph = new QueryableGraph()
graph.LoadFromFile(modelSrc, TurtleParser())

let xsdPath =
Path.Combine(Directory.GetCurrentDirectory(), "Some.xsd")

let ontologyPath =
Path.Combine(Directory.GetCurrentDirectory(), "Some.ttl")

let ontoGraph = new OntologyGraph()
FileLoader.Load(ontoGraph, ontologyPath)

let validationErrors =
GraphValidation.validate xsdPath ontoGraph "http://company.com/meh" graph

if List.isEmpty validationErrors then
Ok graph
else
Error validationErrors
"""
config
|> prepend newline
|> should
equal
"""
let private parseModel (modelSrc: string) : Result<MyReturnType, string list> =
if not (File.Exists(modelSrc)) then
Error [ sprintf "Provided modelSrc \"%s\" does not exist" modelSrc ]
else

let graph = new QueryableGraph()
graph.LoadFromFile(modelSrc, TurtleParser())

let xsdPath =
Path.Combine(Directory.GetCurrentDirectory(), "Some.xsd")

let ontologyPath =
Path.Combine(Directory.GetCurrentDirectory(), "Some.ttl")

let ontoGraph = new OntologyGraph()
FileLoader.Load(ontoGraph, ontologyPath)

let validationErrors =
GraphValidation.validate xsdPath ontoGraph "http://company.com/meh" graph

if List.isEmpty validationErrors then
Ok graph
else
Error validationErrors
"""
2 changes: 1 addition & 1 deletion src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ let private shouldNotIndentBranch e es =
match e with
| SimpleExpr _
| Sequential (_, _, true)
| App (SimpleExpr _, [ SimpleExpr _ ]) -> true
| App _ -> true
| _ -> false

let isLongElseBranch e =
Expand Down