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

Add explicit return to JuliaFormatter and docs #953

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

clizbe
Copy link
Member

@clizbe clizbe commented Dec 6, 2024

Related issues

Closes #796
Closes #940

Checklist

  • I am following the contributing guidelines

  • Tests are passing

  • Lint workflow is passing

  • Docs were updated and workflow is passing

@clizbe
Copy link
Member Author

clizbe commented Dec 6, 2024

I'm not sure all the files should be changed with adding 'return.'
I ran JuliaFormatter using format(".") which might touch files we don't normally format.

@clizbe clizbe requested a review from abelsiqueira December 6, 2024 15:38
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.99%. Comparing base (2273603) to head (345ad10).

Files with missing lines Patch % Lines
src/io.jl 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #953      +/-   ##
==========================================
+ Coverage   94.94%   94.99%   +0.05%     
==========================================
  Files          29       29              
  Lines        1068     1079      +11     
==========================================
+ Hits         1014     1025      +11     
  Misses         54       54              

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

@@ -198,6 +198,7 @@ We will try to follow these during development and reviews.
- List obvious objects, e.g., `using JuMP: @variable`, since `@variable` is obviously from JuMP in this context, or `using Graph: SimpleDiGraph`, because it's a constructor with an obvious name.
- For other objects inside `Package`, use `using Package: Package` and explicitly call `Package.A` to use it, e.g., `DataFrames.groupby`.
- List all `using` in <src/TulipaEnergyModel.jl>.
- Explicitly state what a function will `return`, including `return nothing`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Explicitly state what a function will `return`, including `return nothing`.
- Explicitly state what a function will `return`, including `return nothing`.

@abelsiqueira
Copy link
Member

Indeed, many places will be changed with this new rule because all functions return something (implicit rule is to return the last thing in a function). This is annoying, but necessary with this change. For most places, we are going to need manual intervention to add and empty return before the end to reflect the desired behaviour (assuming the desired behaviour is to return nothing for functions that are not expected to return anything)

@clizbe
Copy link
Member Author

clizbe commented Dec 17, 2024

@abelsiqueira I fixed a lot of them, but the rest I'm not sure if it was an implicit return or returning nothing.
Also I changed the docs to just return instead of return nothing since it looks like that's what we were using (and in my opinion it looks better).

@clizbe
Copy link
Member Author

clizbe commented Dec 17, 2024

Dangit I dunno why the conflict merger never works for me. I must be skipping a step. -_-

Copy link
Member

@abelsiqueira abelsiqueira left a comment

Choose a reason for hiding this comment

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

Thanks for the update. I marked a few places, which are the most relevant. The files in utils/scripts don't matter, because they won't be run again, so I haven't reviewed whether it should be an empty return or not.

When it's ready to be merged, please mark as ready to review, I'll approve, and we can try to merge at a moment that avoids conflicts (since it's changing a bunch of files)

@clizbe
Copy link
Member Author

clizbe commented Dec 18, 2024

Thanks! Yeah sorry for jumping in and creating conflicts.
Just got bored and missed coding!

@clizbe clizbe marked this pull request as ready for review December 18, 2024 10:27
@abelsiqueira abelsiqueira changed the title 796 always return Add explicit return to JuliaFormatter and docs Dec 19, 2024
Copy link
Member

@abelsiqueira abelsiqueira left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. @datejada and I will merge it now, but we'll rebase your branch ourselves

@abelsiqueira abelsiqueira merged commit ed0ff5f into TulipaEnergy:main Dec 19, 2024
4 of 5 checks passed
@clizbe clizbe deleted the 796_always_return branch January 6, 2025 14:43
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.

Update JuliaFormater options Add formatter option to have explicit returns
2 participants