Skip to content

Add uncrustify config#28

Open
jonaski wants to merge 1 commit intomasterfrom
uncrustify
Open

Add uncrustify config#28
jonaski wants to merge 1 commit intomasterfrom
uncrustify

Conversation

@jonaski
Copy link
Member

@jonaski jonaski commented Dec 16, 2025

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Dec 16, 2025

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • uncrustify.cfg

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch uncrustify

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jonaski
Copy link
Member Author

jonaski commented Dec 16, 2025

@coderabbitai
Can you adjust the uncrustify configuration to match the current code style?

In collectiondirectory.h,

CollectionDirectory() : id(-1) {}

should not be changed to:

  CollectionDirectory() : id(-1) {
  }

in collectionbackend.h, the following:

    Album(const QString &_album_artist, const QString &_album, const bool _art_embedded, const QUrl &_art_automatic, const QUrl &_art_manual, const bool _art_unset, const QList<QUrl> &_urls, const Song::FileType _filetype, const QString &_cue_path)
        : album_artist(_album_artist),
          album(_album),
          art_embedded(_art_embedded),
          art_automatic(_art_automatic),
          art_manual(_art_manual),
          art_unset(_art_unset),
          urls(_urls),
          filetype(_filetype),
          cue_path(_cue_path) {}

should not be changed to:

Album(const QString &_album_artist, const QString &_album, const bool _art_embedded, const QUrl &_art_automatic, const QUrl &_art_manual, const bool _art_unset, const QList<QUrl> &_urls, const Song::FileType _filetype, const QString &_cue_path) : album_artist(_album_artist), album(_album), art_embedded(_art_embedded), art_automatic(_art_automatic), art_manual(_art_manual), art_unset(_art_unset), urls(_urls), filetype(_filetype), cue_path(_cue_path) {}

The current formatting should be untouched.

@coderabbitai
Copy link

coderabbitai bot commented Dec 16, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

# Find the uncrustify configuration file
echo "=== Finding uncrustify config file ==="
fd -t f "uncrustify" 

echo -e "\n=== Looking for collectiondirectory.h ==="
fd -t f "collectiondirectory.h"

echo -e "\n=== Looking for collectionbackend.h ==="
fd -t f "collectionbackend.h"

Length of output: 244


🏁 Script executed:

#!/bin/bash

echo "=== Current uncrustify.cfg content ==="
cat uncrustify.cfg

echo -e "\n\n=== Examining collectiondirectory.h for the constructor ==="
grep -A 5 -B 2 "CollectionDirectory()" src/collection/collectiondirectory.h

echo -e "\n\n=== Examining collectionbackend.h for Album constructor ==="
grep -A 15 "Album(const QString &_album_artist" src/collection/collectionbackend.h

Length of output: 150314


🏁 Script executed:

#!/bin/bash

# Create test files with the exact patterns the user wants to preserve
cat > /tmp/test_constructor1.h << 'EOF'
struct CollectionDirectory {
  CollectionDirectory() : id(-1) {}
};
EOF

cat > /tmp/test_constructor2.h << 'EOF'
class Test {
    Album(const QString &_album_artist, const QString &_album, const bool _art_embedded, const QUrl &_art_automatic, const QUrl &_art_manual, const bool _art_unset, const QList<QUrl> &_urls, const Song::FileType _filetype, const QString &_cue_path)
        : album_artist(_album_artist),
          album(_album),
          art_embedded(_art_embedded),
          art_automatic(_art_automatic),
          art_manual(_art_manual),
          art_unset(_art_unset),
          urls(_urls),
          filetype(_filetype),
          cue_path(_cue_path) {}
};
EOF

# Test current configuration
echo "=== Testing current config on single-line constructor ==="
uncrustify -c uncrustify.cfg -f /tmp/test_constructor1.h

echo -e "\n=== Testing current config on multi-line constructor ==="
uncrustify -c uncrustify.cfg -f /tmp/test_constructor2.h

# Check relevant settings in current config
echo -e "\n=== Current settings for empty function bodies ==="
grep -E "^(nl_collapse_empty_body|nl_inside_empty_func|nl_fdef_brace|nl_func_class_paren_empty|nl_after_brace_open|nl_before_brace_close)" uncrustify.cfg

Length of output: 689


@jonaski I've analyzed the uncrustify configuration and identified the settings that need adjustment to preserve your code style. Here are the specific changes needed:

Configuration Adjustments

Based on your requirements, you need to modify these settings in uncrustify.cfg:

# Preserve one-line functions (including constructors) - ALREADY SET CORRECTLY
nl_func_leave_one_liners        = true    # true/false
nl_class_leave_one_liners       = true    # true/false

# Collapse empty function bodies - ALREADY SET CORRECTLY  
nl_collapse_empty_body_functions = true    # true/false
nl_inside_empty_func            = 0        # unsigned number

# Keep braces on same line for functions - ALREADY SET CORRECTLY
nl_fdef_brace                   = remove   # ignore/add/remove/force
nl_fdef_brace_cond              = remove   # ignore/add/remove/force

# CHANGE THIS - it may be forcing newlines after { in some contexts
# Set to false to prevent adding newlines after { in empty functions
nl_after_brace_open             = false    # true/false

# OR if you want to keep nl_after_brace_open = true for other contexts,
# you can use this option to specify empty function behavior:
nl_after_brace_open             = true     # true/false
# And ensure empty bodies are exempted with these:
nl_inside_empty_func            = 0        # unsigned number (no newlines inside {})

Key Changes

The main issue is likely nl_after_brace_open = true. This setting adds a newline after every {, which conflicts with keeping empty function bodies on one line.

Option 1 (Recommended): Change nl_after_brace_open from true to false:

nl_after_brace_open             = false    # true/false

Option 2: If you need nl_after_brace_open = true for non-empty function bodies, the current settings should already handle empty functions correctly with:

  • nl_collapse_empty_body_functions = true
  • nl_inside_empty_func = 0

Would you like me to generate a complete updated uncrustify.cfg file with these changes, or would you prefer to test Option 1 first to see if it resolves both formatting issues?

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.

1 participant