This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Uncrustify
Uncrustify can be used to beautify your source code. In other words, Uncrustify makes sure that you follow the Code Guidelines
Download
Something to note is that you are supposed to use only Uncrustify v0.73
- For Windows, you can download Uncrustify from here
- For Linux, even though you can download it using
apt-get
, it might not offer v0.73. Therefore, you might have to download it from here - Or just download source code (https://github.com/uncrustify/uncrustify/releases/tag/uncrustify-0.73.0) and build (instruction). It's very easy to do
- Note there is a potential bug in Uncrustify 0.73 when building on MacOS. If you're getting build errors relating to
std::map
, it is likely you need to move#include <map>
outside the WIN32#ifdef
at the top ofsrc/output.cpp
Extract
After extracting the contents, you would want to move it to a better place, say Program Files (if you are on Windows)
And add the path of uncrustify to PATH environment.
Beautifying Code
Now there are three main ways to run to beautify your code:
- Run the Uncrustify script manually to fix the code style in your repository
- Add it to your Git Pre-commit hook, so that your changed files will be fixed up just before you commit (that way, you really never have to think about it)
- Add it to IDE so that it beautifies your code on saving
Feel free to choose any or all of the three
Running Uncrustify Manually
To beautify this way, you can just run the script in tools/codestyle/uncrustify_run.sh
, with as working directory the MuseScore folder.
Adding to Git Pre-commit hook
Copy the file in hooks/pre-commit.sh
to .git/hooks/pre-commit
Adding to QtCreator
- Open Qt Creator
- Click the checkmark on Help → About Plugins → C++ → Beautifier
- Click close and you will be prompted to restart Qt Creator. Therefore, do so
- Click Edit → Preferences... → Beautifier section in the left panel
- Now, check
Enable auto format on file save
and also change the tool to Uncrustify - Now go to the Uncrustify tab
- Put in your the path of uncrustify.exe (which is in bin in the Uncrustify folder) or simply browse it
- Uncheck
Use file uncrustify.cfg defined in project files
and now checkUse file specific uncrustify.cfg
and input the path of .cfg file which is located astools/codestyle/uncrustify_musescore.cfg
of the MuseScore repository (You need the whole path)
Uncrustify should now work on saving the file
Adding to VSCode
- Install extension "Uncrustify"
- Open vscode settings, and find "Uncrustify"
- Set
Uncrustify › Config Path:
path/to/MuseScore/tools/codestyle/uncrustify_musescore.cfg
- Find "Format"
- Set
Editor: Format On Save
on - Restart VSCode
Uncrustify should now work on saving the file
Testing
- Manual testing
- Automatic testing
Translation
Compilation
- Set up developer environment
- Install Qt and Qt Creator
- Get MuseScore's source code
- Install dependencies
- Compile on the command line
- Compile in Qt Creator
Beyond compiling
- Find your way around the code
- CMake and the build system
- Submit a Pull Request
- Fix the unit tests
- Uncrustify (Code Beautifier)
Architecture general
- Architecture overview
- AppShell
- Modularity
- Interact workflow
- Channels and Notifications
- Settings and Configuration
- Error handling
- Launcher and Interactive
- Keyboard Navigation
Audio
Engraving
- Style settings
- Style Parameter changes between 3.6 and 4.0
- Style Parameter changes between 4.0 and 4.1
- Style Parameter changes between 4.1 and 4.2
References