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

[Format range] Add --range as a command line option. #299

Merged
merged 4 commits into from
Jun 4, 2021

Conversation

slaykachu
Copy link
Contributor

No description provided.

This commit plugs the CLI option to existing range formatting function.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 3, 2021
}.

resolve_width(undefined, W) -> W;
resolve_width(W, _) -> W.
resolve_undefined(undefined, W) -> W;
Copy link
Contributor

Choose a reason for hiding this comment

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

A nit, take it or leave it
But I preferred having verbose functions for each parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argl, it would trigger my DRY obsession!

Copy link
Contributor

Choose a reason for hiding this comment

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

No problem, but just to explain where my review is coming from.
I prefer readability over DRY.
DRY is only important to me if it removes a large maintenance burden.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having two functions doing the same thing doesn't match my definition of readability :)
'Same things should share a same name, different things should have distinct names'
Yet, I don't have strong feelings for this one, so I've switched back to one function per parameter.

src/erlfmt.erl Outdated
@@ -234,7 +262,7 @@ format_file_range(FileName, StartLocation, EndLocation, Options) ->
string(),
erlfmt_scan:location(),
erlfmt_scan:location(),
[{print_width, pos_integer()}]
config()
Copy link
Contributor

Choose a reason for hiding this comment

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

The options verbose and pragma are not supported by this function, that is why this is a smaller property list.
Could we change this back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, the range was extracted for dispatching purpose, but still sits in this properly list. Would I rather:

  • Remove it from the properly list? Con: that's additional work just to
  • Introduce a sub_config() type with just print_width and range?
  • Other. Con: I have no idea what this alternative is.

Copy link
Contributor

Choose a reason for hiding this comment

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

We want the function spec to only support what the function actually can support and not say that it can actually influence verbosity or where the output goes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@awalterschulze awalterschulze merged commit 6e9ecad into WhatsApp:master Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants