-
Notifications
You must be signed in to change notification settings - Fork 18
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
Apply standard formatting across the board #73
Conversation
Not a bad idea in general. Have been meaning to get into it myself as it has reached a stage... Right, now I'll actually go look about what annoys me about the default ruleset, hoping to be pleasantly surprised! |
| False | ||
| True -> invalidOp "internal error: invalid query representation" | ||
| Not q -> | ||
! "( NOT " |
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.
this sort of stuff is just bad news - maybe if there was a prettier ignore
annotation you could att at function level?
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.
Pretty sure you can only ignore at file level
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.
maybe thats the thing to do as the bulk of files do seem mostly fine overall
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.
seems cured, will delete this thread after
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.
wait, not sure why I thought it was cured, leaving comment here
@@ -515,11 +585,10 @@ type ConditionalExpression with | |||
let values = aw.Values |> Seq.map (fun kv -> kv.Key, kv.Value.Print()) |> Seq.toList | |||
expr, names, values | |||
|
|||
static member Extract (recordInfo : RecordTableInfo) (expr : Expr) = | |||
extractQueryExpr recordInfo expr | |||
static member Extract (recordInfo: RecordTableInfo) (expr: Expr) = extractQueryExpr recordInfo expr |
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.
I think this is all based on line length - it’s not necessarily going to be consistent
OK, ultimately I know fantomas is the right thing to do The result is that it works really badly with handf ormatted consistent code like equinox, e.g. jet/equinox#345 (see my mainline comment there on my stance) What to do here? Main thing is to measure twice, cut once. The main risk here is that a hand formatted parser with necessarily large blocks of logic which is non trivial to understand is really not helped by being stretched to twice the line count - there were enough of those in my quick traverse to nor make me want to do it if it was my project. While the formatter demonstrates that Eirik was not 100% consistent, ultimately his code in 2014 was setting standards for legible layout without any fantomas in the picture. Regularising it is going to lose some value. But there is a win too if it aligns with sister projects that people are likely to have read and/or eventually will read in conjunction with it. My hunch is that taking the TaskSeq ruleset and living with that might be a better answer as it didnt offend me too much despite being picky and working across plenty projects. But I won't fight on using the defaults, as plenty projects do that and its not like the fantomas folk dont have internal style debates. |
also nojaf (was going to at him, but people have enough to do) and I have yet to apply it to Argu, which will likely have similar issues |
Okay, I’ve been through the TaskSeq config and removed the obsolete settings etc. Still no luck with the pattern
With the space-before-DU the only setting is Agree in general re formatters - I avoided them for a long time but they are quite liberating once you get used to them. Sure it doesn’t always result in code the way I would have done it, but I didn’t have to do it... |
|
||
let names = | ||
aw.Names | ||
|> Seq.map (fun kv -> kv.Key, kv.Value) |
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.
maaaan (though the answer is to rewrite it as [ for kv in aw.Names -> kv.Key, kv.Value]
)
sprintf "Document path '%s' not found." id.Name |> KeyNotFoundException |> raise | ||
sprintf "Document path '%s' not found." id.Name | ||
|> KeyNotFoundException | ||
|> raise |
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.
argh! I guess the rule is >=2 pipes means multi line
I'd prob write raise (KeyNotFoundException($"..."))
if it did this to me
but fine
Looking better but seems cure is worse than disease if spaces before DU ctor args means space before method args and all other ctor args |
It does seem to be getting decent Can prob do stupid things like converting ifs to matches to fight the formatter lol |
override __.GetHashCode() = hash expr.Attributes |
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.
also need to do an F# syntax update - Rider can bulk fix these
sprintf "Document path '%s' not found." id.Name | ||
|> KeyNotFoundException | ||
|> raise | ||
sprintf "Document path '%s' not found." id.Name |> KeyNotFoundException |> raise |
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.
I’m not sold on one-lining these, having the raise
at the end of the line is less obvious than having it at the bottom of the chain. I can experiment with winding back the infix expression length a bit but the likelihood is it will catch some & not others.
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.
yes 2 pipes on a line is def the limit
and I prefer the raise
to stick out
as mentioned I'd map that to raise (KeyNotFoundException $"...")
but sreading it over 3 lines doesnt really help anyone IMO other than forcing them to think, which is great of course
values | ||
|> Seq.map (function | ||
| AttributeGet qa -> qa | ||
| _ -> invalidExpr ()) |
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.
There doesn't appear to be a max expression length for match
/function
; it always breaks.
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.
maybe that's not the end of the world in this instance - it can work well for short one liner option matches, but I guess its also something that gets taken too far (speaking personally 😊 )
Picking this up again - the main change I’ve made is adding the I’ve also turned off |
I think the main part that’s still substantially ugly(er) than previous are those multiple-expression-lines in the query writing code. The option is always there to exclude those and manually format but it’s probably not worth the tradeoff. @bartelink I agree most of the other quirks would be better handled by changing code structure instead. When that will happen I don’t know though... |
@@ -281,11 +271,9 @@ type ManyReadOnlyItemsFixture() = | |||
let table = base.CreateEmpty<MetricsRecord>() | |||
|
|||
let hk = guid () | |||
|
|||
do |
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.
for these, I'm wondering if the do
can go on the same line, or does it separate it if you do (very minor of course)
Looks to have worked very well. On balance its positive for the codebase so I'd call it done. |
This applies pretty much just the default fantomas rules as a baseline & to get the monster diff out of the way. I’m not particularly religious about style so open to change if needed.
Also addressed previous test feedback in 9e08062