Skip to content

Remove clang-format integration due to incompatibility with minimal formatting requirements#28

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/fix-7f4082b7-0dbd-4f15-9268-444e8ad769ff
Closed

Remove clang-format integration due to incompatibility with minimal formatting requirements#28
Copilot wants to merge 4 commits intomainfrom
copilot/fix-7f4082b7-0dbd-4f15-9268-444e8ad769ff

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 2, 2025

Removed clang-format integration

After analysis and feedback, clang-format has been determined to be incompatible with the requirement for minimal, surgical formatting changes.

Issue

clang-format is designed as a complete code formatter and cannot make only specific minimal changes (fixing space before '(', spacing around binary operators, and space after comma) without also reformatting other aspects including:

  • Pointer alignment
  • Brace placement
  • Multi-line macro formatting
  • Preprocessor indentation
  • Line breaks
  • Comment formatting

Changes Made

All clang-format related changes have been reverted:

  • Removed .clang-format configuration file
  • Removed clang-format hook from .pre-commit-config.yaml
  • Restored all C/C++ files to their original formatting
  • Removed documentation about clang-format from DEVEL-README.md

Current State

The code is back to its original state before any formatting was attempted. No formatting changes have been applied to the C/C++ codebase.

Alternatives

To address the specific spacing issues requested, alternative approaches would be needed:

  1. Manual fixes on a case-by-case basis
  2. Custom linting rules that flag but don't auto-fix issues
  3. A different tool designed for minimal style fixes
Original prompt

Run clang-format for C/C++ code on pre-commit. The style enforced by clang-format should follow as close as possible the current style of the C/C++ code. The differences between the current code and the result after applying clang-format should be minimized.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title Run clang-format for C/C++ code on pre-commit. The style enforced by clang-format should follow as close as possible the current style of the C/C++ code. The differences between the current code and the result after applying clang-format should be mini... Add clang-format for C/C++ code formatting on pre-commit Oct 2, 2025
Copilot AI requested a review from MLopez-Ibanez October 2, 2025 11:30
@MLopez-Ibanez
Copy link
Copy Markdown
Contributor

@copilot

  • Do not reformat switches like the ones in c/pow_int.h
  • Do not reformat avl.c and avl.h
  • Do not reformat the files under the c/mt19937/ folder.
  • Allow spaces between '#' and preprocessor directives to denote nesting level.
  • If a conditional statement or a loop contains a single expression and fits within the same line, do not move it to the next line. For example, do not change the following code:
            if (r >= rectangles_nrow) break; // goto next_point

Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot

  • Do not reformat switches like the ones in c/pow_int.h
    ...

All requested changes have been addressed in commit 329ba8b:

  • ✅ Excluded pow_int.h from formatting (restored original)
  • ✅ Excluded avl.c and avl.h from formatting (restored original)
  • ✅ Excluded files under c/mt19937/ from formatting (restored original)
  • ✅ Configured IndentPPDirectives: AfterHash to preserve spaces after # for nesting level (e.g., # define, # define)
  • ✅ Configured AllowShortIfStatementsOnASingleLine: WithoutElse and AllowShortLoopsOnASingleLine: true to preserve single-line conditionals like if (r >= rectangles_nrow) break;

The pre-commit configuration now excludes the specified files via: exclude: ^c/(pow_int\.h|avl\.(c|h)|mt19937/.*)

@MLopez-Ibanez
Copy link
Copy Markdown
Contributor

@copilot This clang-format style is changing too many things at once. Please limit the formatting changes to:

  • Fix wrong use of space or missing space before '('.
  • Fix no spacing around binary operators.
  • Add space after comma.

Do not change anything else in the code.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot This clang-format style is changing too many things at once. Please limit the formatting changes to:

  • Fix wrong use of space or missing space before '('.
    ...

I understand the concern. Unfortunately, clang-format is designed as a complete code formatter and doesn't have options to make ONLY the three specific changes you requested (missing space before '(', spacing around binary operators, and space after comma) without also changing other formatting aspects like:

  • Pointer alignment
  • Brace placement
  • Multi-line macro formatting
  • Preprocessor indentation
  • Line breaks

Making such minimal, surgical changes would require a custom tool with regex-based replacements, which is error-prone and could break code (e.g., affecting email addresses in comments, include statements, etc.).

Given these limitations, I've reverted all the clang-format changes and removed it from the pre-commit hooks. The code is now back to its original state before any formatting was applied.

If you'd still like these specific spacing issues addressed, I'd recommend either:

  1. Fixing them manually on a case-by-case basis
  2. Creating a custom linting rule that flags but doesn't auto-fix these issues
  3. Using a different tool designed for minimal style fixes

Let me know how you'd like to proceed.

Copilot AI changed the title Add clang-format for C/C++ code formatting on pre-commit Remove clang-format integration due to incompatibility with minimal formatting requirements Oct 2, 2025
@MLopez-Ibanez MLopez-Ibanez deleted the copilot/fix-7f4082b7-0dbd-4f15-9268-444e8ad769ff branch October 2, 2025 12:36
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.

2 participants