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

Formatting #464

Merged
merged 1 commit into from
Jun 14, 2023
Merged

Formatting #464

merged 1 commit into from
Jun 14, 2023

Conversation

baumgold
Copy link
Member

I used the default JuliaFormatter options, but we can customize them if we want to with a .JuliaFormatter.toml file. Details available here:

https://domluna.github.io/JuliaFormatter.jl

Fixes #398. CC: @svilupp

@codecov-commenter
Copy link

codecov-commenter commented Jun 12, 2023

Codecov Report

Merging #464 (420df67) into main (5532270) will decrease coverage by 82.60%.
The diff coverage is 8.21%.

@@            Coverage Diff             @@
##             main    #464       +/-   ##
==========================================
- Coverage   87.53%   4.93%   -82.60%     
==========================================
  Files          26      25        -1     
  Lines        3272    3199       -73     
==========================================
- Hits         2864     158     -2706     
- Misses        408    3041     +2633     
Impacted Files Coverage Δ
src/Arrow.jl 0.00% <0.00%> (-97.44%) ⬇️
src/FlatBuffers/FlatBuffers.jl 0.00% <0.00%> (-93.34%) ⬇️
src/FlatBuffers/builder.jl 0.00% <0.00%> (-80.12%) ⬇️
src/FlatBuffers/table.jl 0.00% <0.00%> (-60.00%) ⬇️
src/append.jl 0.00% <0.00%> (-92.05%) ⬇️
src/arraytypes/arraytypes.jl 0.00% <0.00%> (-90.00%) ⬇️
src/arraytypes/bool.jl 0.00% <0.00%> (-88.71%) ⬇️
src/arraytypes/compressed.jl 0.00% <0.00%> (-100.00%) ⬇️
src/arraytypes/dictencoding.jl 0.00% <0.00%> (-75.59%) ⬇️
src/arraytypes/fixedsizelist.jl 0.00% <0.00%> (-84.54%) ⬇️
... and 15 more

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Comment on lines 74 to 75
for (i, ind) in enumerate(off:(off+sizeof(T)-1))
sink.bytes[ind] = (x >> ((i - 1) * 8)) % UInt8
Copy link
Member

Choose a reason for hiding this comment

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

What the? what's the rule here? it seems to usually take away spaces in the 1st line, but adds them in the 2nd?

@@ -72,7 +76,7 @@ function bytevector(t::Table, off)
off += get(t, off, UOffsetT)
start = off + sizeof(UOffsetT)
len = get(t, off, UOffsetT)
return view(bytes(t), (start + 1):(start + len + 1))
return view(bytes(t), (start+1):(start+len+1))
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it's range-specific where it prefers to remove spaces?

@quinnj
Copy link
Member

quinnj commented Jun 12, 2023

I think this is mostly great and I agree we should do it. I think the only change I'm really against is removing spaces around operators, regardless of where or what kind of clause they occur in. I also personally prefer keeping spaces around the <: operator in type parameter clauses, but I don't feel as strongly about that if people prefer otherwise.

@quinnj
Copy link
Member

quinnj commented Jun 12, 2023

@baumgold, can you clarify the CI change here? Does it automatically add a commit w/ formatting changes to your PR? Or post suggestions that can be committed?

@baumgold
Copy link
Member Author

I think this is mostly great and I agree we should do it. I think the only change I'm really against is removing spaces around operators, regardless of where or what kind of clause they occur in. I also personally prefer keeping spaces around the <: operator in type parameter clauses, but I don't feel as strongly about that if people prefer otherwise.

I believe the only control for this that we are given in JuliaFormatter is the following:

https://github.com/domluna/JuliaFormatter.jl#whitespace_ops_in_indices

I overrode the default from false to true. That seems like it should mostly fix this issue.

@baumgold
Copy link
Member Author

@baumgold, can you clarify the CI change here? Does it automatically add a commit w/ formatting changes to your PR? Or post suggestions that can be committed?

I think the CI change can be simplified using the "julia-format" GitHub action. I'll try to get this setup shortly.

https://github.com/julia-actions/julia-format

@baumgold
Copy link
Member Author

baumgold commented Jun 12, 2023

I was trying to using the julia-format GitHub action but I can't seem to get it to work. Instead I took inspiration from the following example but simplified it as much as possible for use here.

https://github.com/julia-actions/julia-format/blob/master/workflows/format_check.yml

The expected behavior is that if a PR is opened with malformed code then the format build will fail indicating that the PR should not be merged until the formatting is fixed.

@ericphanson
Copy link
Member

ericphanson commented Jun 13, 2023

Something I often do at work is check in a format directory with a Project and Manifest, a small run.jl script that does the formatting and a readme to explain how. Then the CI job can use the same project/manifest to do the check. This can allow folks to easily run the formatting locally and also ensure that JuliaFormatter updates don’t suddenly cause the CI check to fail on unrelated PRs. (Then if eg a new contributor’s PR fails the format check there is an easy remedy for them - to run the local run script in the format project).

One needs to manually PR the format manifest to update it for newer JuliaFormatter versions but imo that’s worth it being explicit (and you only need to update if there’s some specific change you want).

This may be less necessary as JuliaFormatter has gotten more stable over the years.

@baumgold
Copy link
Member Author

@ericphanson - That script you speak of is embedded in the ci.yml file:

https://github.com/apache/arrow-julia/pull/464/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR165-R179

IMHO it's quite a trivial script. We can explicitly pin to a version of JuliaFormatter if we want but that adds extra maintenance overhead so would prefer not to unless there's a good reason. What do you think? Is this sufficient?

@baumgold
Copy link
Member Author

@quinnj / @ericphanson - shall I merge? Any objections?

@quinnj
Copy link
Member

quinnj commented Jun 13, 2023

Go for it

@baumgold baumgold merged commit fc7cc2d into apache:main Jun 14, 2023
@baumgold baumgold deleted the formatting branch June 14, 2023 00:16
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.

Introduce automatic code formatting with JuliaFormatter.toml
4 participants