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

Apply Runic.jl formatter #2070

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

efaulhaber
Copy link
Member

Copy link
Contributor

github-actions bot commented Sep 9, 2024

Review checklist

This checklist is meant to assist creators of PRs (to let them know what reviewers will typically look for) and reviewers (to guide them in a structured review process). Items do not need to be checked explicitly for a PR to be eligible for merging.

Purpose and scope

  • The PR has a single goal that is clear from the PR title and/or description.
  • All code changes represent a single set of modifications that logically belong together.
  • No more than 500 lines of code are changed or there is no obvious way to split the PR into multiple PRs.

Code quality

  • The code can be understood easily.
  • Newly introduced names for variables etc. are self-descriptive and consistent with existing naming conventions.
  • There are no redundancies that can be removed by simple modularization/refactoring.
  • There are no leftover debug statements or commented code sections.
  • The code adheres to our conventions and style guide, and to the Julia guidelines.

Documentation

  • New functions and types are documented with a docstring or top-level comment.
  • Relevant publications are referenced in docstrings (see example for formatting).
  • Inline comments are used to document longer or unusual code sections.
  • Comments describe intent ("why?") and not just functionality ("what?").
  • If the PR introduces a significant change or new feature, it is documented in NEWS.md with its PR number.

Testing

  • The PR passes all tests.
  • New or modified lines of code are covered by tests.
  • New or modified tests run in less then 10 seconds.

Performance

  • There are no type instabilities or memory allocations in performance-critical parts.
  • If the PR intent is to improve performance, before/after time measurements are posted in the PR.

Verification

  • The correctness of the code was verified using appropriate tests.
  • If new equations/methods are added, a convergence test has been run and the results
    are posted in the PR.

Created with ❤️ by the Trixi.jl community.

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 95.67901% with 7 lines in your changes missing coverage. Please review.

Project coverage is 96.28%. Comparing base (f9c9107) to head (5b633f1).

Files with missing lines Patch % Lines
...les/p4est_2d_dgsem/elixir_euler_double_mach_amr.jl 0.00% 4 Missing ⚠️
...p4est_2d_dgsem/elixir_euler_supersonic_cylinder.jl 0.00% 2 Missing ⚠️
...es/p4est_2d_dgsem/elixir_euler_forward_step_amr.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2070      +/-   ##
==========================================
- Coverage   96.32%   96.28%   -0.05%     
==========================================
  Files         470      470              
  Lines       37447    37511      +64     
==========================================
+ Hits        36070    36114      +44     
- Misses       1377     1397      +20     
Flag Coverage Δ
unittests 96.28% <95.68%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ranocha
Copy link
Member

ranocha commented Sep 9, 2024

Do you have an idea why CI fails?

Comment on lines 5 to -6
@muladd begin
#! format: noindent
Copy link
Member

Choose a reason for hiding this comment

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

Sadly, all of our source files will be indented because of this...

Copy link
Member Author

Choose a reason for hiding this comment

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

There seems to be no way around it. I tried

# runic: off
@muladd begin
# runic: on

but this just disables formatting for the whole file.

Copy link
Member

Choose a reason for hiding this comment

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

Create an issue for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

@efaulhaber efaulhaber Sep 10, 2024

Choose a reason for hiding this comment

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

See the reply in the linked issue. We don't use this "wrapping full files in @muladd" thing in TrixiParticles.jl, so I don't really care about this indent.

@efaulhaber
Copy link
Member Author

efaulhaber commented Sep 9, 2024

Do you have an idea why CI fails?

That seems to be a bug in Runic.jl:

julia> Runic.format_string("x, = (1, 2, 3)")
"x = (1, 2, 3)"

That is, of course, not equivalent:

julia> x, = (1, 2, 3); x
1

julia> x = (1, 2, 3); x
(1, 2, 3)

Edit: fredrikekre/Runic.jl#58

@efaulhaber
Copy link
Member Author

Already fixed.

@KristofferC
Copy link

Maybe you are aware but I want to point out https://gist.github.com/kateinoigakukun/b0bc920e587851bfffa98b9e279175f2 so you can keep the blame functionality working without everything pointing to this PR modifying it.

Comment on lines -21 to -36
filename :: String
n_corners :: Int
n_surfaces :: Int # total number of surfaces
n_interfaces :: Int # number of interior surfaces
n_boundaries :: Int # number of surfaces on the physical boundary
n_elements :: Int
polydeg :: Int
corners :: Array{RealT, 2} # [ndims, n_corners]
neighbour_information :: Array{Int, 2} # [neighbour node/element/edge ids, n_surfaces]
boundary_names :: Array{Symbol, 2} # [local sides, n_elements]
periodicity :: Bool
element_node_ids :: Array{Int, 2} # [node ids, n_elements]
element_is_curved :: Vector{Bool}
surface_curves :: Array{CurvedSurfaceT, 2} # [local sides, n_elements]
current_filename :: String
unsaved_changes :: Bool # if true, the mesh will be saved for plotting
Copy link
Member Author

Choose a reason for hiding this comment

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

This alignment was a cool feature in JuliaFormatter.jl.

Choose a reason for hiding this comment

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

Does it really increase the readability of the code though? (This) code isn't read column by column but row by row.

While creating Runic I have thought a bit about things like this. I also used to sometimes align things like thisbut I have realized that usually it is just to make me "feel better", it doesn't really increase the readability. When you stop worrying about things like this while writing the code (e.g. press space multiple times to align) and just accept the formatters rules it kind of gives a similar peace of mind. 🙂

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it does. I can clearly see which are scalar values and which are the big arrays that I might be looking for.

@efaulhaber
Copy link
Member Author

Before we discuss this newly formatted code to decide if we want to use Runic.jl, note the following:

Note that currently there is no line-length limit employed so expressions that only take up a single line, even if they are long, are not formatted like the above. Thus, only expressions where the original author have "committed" to mulitples lines are affected by this rule.

I think it wouldn't be wise to use Runic.jl at this point, as we would end up with PR comments like "please split this long line", which were the main reason why we introduced automatic formatting in the first place. Once this feature exists, we can re-evaluate.

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.

5 participants