Skip to content

Conversation

@dean-krueger
Copy link
Contributor

Summary of Changes

This (massive, sorry) PR does three things: adds //clang-format off and //clang-format on protection to all #pragma blocks in cycamore/src, cleans up some of the #pragma blocks/checks spelling and grammar in comments, and then runs clang-format on all the files in cycamore/src.

Related CEPs and Issues

This PR is related to:

Associated Developers

@ahnaf-tahmid-chowdhury

Design Notes

This PR, which I expect I will be told should be three PRs because it sort of does three separate (large) things, but which I'm going to do my darnedest to sneak by as one, was submitted as one PR because I used ChatGPT to help with a lot of the manual addition of #pragma protection, and while it was doing that I asked it to run a spelling/grammar/general style check as well. Then, and most importantly, it would have been almost impossible to correctly check that I had done this correctly had I not been able to actually run clang-format on the code, at which point I figured I'd just submit everything since it's all tied together in this way.

Testing and Validation

The code was built locally on my machine. No additional tests were added.

Checklist

  • Read the Contributing to Cyclus guide.
  • Compile and run locally.
  • Add or update tests.
  • Document if needed.
  • Follow style guidelines.
  • Update the changelog.
  • Address all review comments.
    Reviewers, please refer to the Cyclus Guide for Reviewers.

@dean-krueger
Copy link
Contributor Author

One day I'll remember the changelog before making a PR. One day.

@dean-krueger
Copy link
Contributor Author

One final comment about the size of this PR: Because clang-format does so much I figured that instead of three +1500 / - 1496 line changes it might be better to do it all as one massive +3000 / -3000 line PR 😬

@github-actions
Copy link

github-actions bot commented Jul 6, 2025

Build Status Report - 0cb2ab9 - 2025-07-06 12:34:26 -0600

Build FROM cyclus_20.04_apt/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_20.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_20.04_conda/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_20.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_apt/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_22.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_22.04_conda/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_22.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_apt/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_24.04_apt/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️
Build FROM cyclus_24.04_conda/cyclus:latest
  • Cycamore: Success
  • Cymetric: Success
Build FROM cyclus_24.04_conda/cyclus:stable
  • Cycamore: Failure
  • Cymetric: Skipped due to upstream failure ⚠️

@gonuke
Copy link
Member

gonuke commented Jul 6, 2025

I wonder if we can do this in cyclus/cyclus first and then get cyclus/cyclus#1674 implemented? It will need some clang-format "guards" as well for the archetypes that are defined there for testing

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

I found one issue that may be problem when I started reviewing this - clang-format likes to reorder includes to be alphabetical, but we have an expectation (habit? need?) that we include cyclus.h before any other headers. Not sure if we can train clang-format to do something different, or if we have to make some other change to preserve the order.... or make the order less important.

Comment on lines 17 to 18
// These includes must come before others.
#include "cyclus.h"
#include "cycamore_version.h"
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we can force clang-format to not reorder these. I can't recall why these need to come first except that cyclus.h probably includes a whole bunch of stuff that we assume is included before the others are included.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can just protect them with the comments like I do with the pragmas. That'd probably be the most straightforward way to do it.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I found that same post a little while ago. The .clang-format for cyclus has SortIncludes: Never and I think that took care of things. If that's not already in the Cycamore one I'll for sure add it, though!

@dean-krueger
Copy link
Contributor Author

I wonder if we can do this in cyclus/cyclus first and then get cyclus/cyclus#1674 implemented?

On it.

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

I added SortIncludes in a suggestion comment, but I expect the whole code base will need to be reformatted from the original to preserve the original order... formatting in the branch will not sort them back

.clang-format Outdated
# Automatically detect whether a given fuction's arguments are one-per-line
ExperimentalAutoDetectBinPacking: true
# Use C++11 standard
Standard: Cpp11 No newline at end of file
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
Standard: Cpp11
Standard: Cpp11
# prefer to keep includes sorted as we like
SortIncludes: Never

@dean-krueger
Copy link
Contributor Author

dean-krueger commented Aug 19, 2025

Okay two things have now been done here:

  1. The PR now only adds the guard rails (//clang-format off/on) to cycamore, instead of that plus the format (should have put the includes back in the correct order)
  2. The .clang-format document has been updated to be exactly like the one in cyclus/cyclus (added SortIncludes: Never)

@dean-krueger dean-krueger requested a review from gonuke August 19, 2025 18:00
@katyhuff katyhuff removed their request for review September 4, 2025 15:10
@gonuke
Copy link
Member

gonuke commented Sep 4, 2025

This appears to need a rebase...

@gonuke
Copy link
Member

gonuke commented Dec 16, 2025

Pinging @dean-krueger because I think this only needs a rebase to be considered for merging...?

@dean-krueger
Copy link
Contributor Author

On it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Add //clang-format off/on to protect all Cycamore Pragmas for clang-format

2 participants