uncrustify | Code beautifier - Firstly take a look at the CONTRIBUTING
kandi X-RAY | uncrustify Summary
kandi X-RAY | uncrustify Summary
Firstly take a look at the CONTRIBUTING.md. Currently we have two continuous integration systems that test your PRs, TravisCI and Appveyor. Tested are the test cases, the formatting of the code base and the output of the command line options. Test cases can be found in the tests/ directory. Every file ending with .test is a test set. Inside each line with these components is a single test: testNr] testConfigFileName testInputFileName [lang]. The configuration file testConfigFileName has to be located inside tests/config, the input file testInputFileName inside tests/input//, and expected results file inside the tests/expected// directory. Expected results have the following naming convention: testNr-testInputFileName. Optionally a ! can follow the testNr to enable a custom rerun configuration. Rerun configurations need to be named like this: testConfigFileName(without extension)+.rerun+.extension. Also, optionally a language for the input can be provided with lang. The codebase has to be formatted by the options set up in forUncrustifySources.cfg. Failing to format the sources correctly will cause TravisCI build failures. The Command line interface (CLI) output is tested by the test_cli_options.sh script. It is located inside of tests/cli/ and operates on the subdirectories of that folder. If a PR is altering the CLI output, files inside those directories might need to be manually updated. This often happens when options are added, removed or altered. Keep in mind that the version string line (example: # Uncrustify-0.69.0_f) of outputs from commands like --show-config should be replaced with a blank line.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of uncrustify
uncrustify Key Features
uncrustify Examples and Code Snippets
Community Discussions
Trending Discussions on uncrustify
QUESTION
I am trying to to acheive the following every time a file is saved in Vim under Windows 10 (Vim 8.2):
- Auto format the file (using an external tool, e.g. Uncrustify)
- Reload the formatted file in Vim (I want to see the newly formatted file)
Right now I am able using autocmd
to autoformat the file, by adding the following to my .vimrc
:
ANSWER
Answered 2020-Oct-17 at 16:05can't test this on Windows 10 right now, but on Linux I'm trying a similar setup that works:
QUESTION
I setup a clean filter to apply autoformat with uncrustify. The corresponding smudge filter does nothing, it just calls cat
.
ANSWER
Answered 2020-Jan-08 at 17:00It seems that the clean filter is applied before diff. Is that correct?
Yes. In at least some cases it must be. Consider, for instance, what happens if the smudge filter consists of, say, "double every character" and the clean filter consists of "remove the doubling"—or, if that seems too peculiar, if the smudge filter consists of "translate into some alternate character set" and the clean filter translates back.
A git diff
to compare the work-tree against an actual commit must either run the smudge filter on the commit's content, or run the clean filter on the work-tree's content. Or it might even run both, with the output going to temporary files. (I'm pretty sure I tested this once, long ago, and found that the approach Git used was to run the clean filter, rather than the smudge filter. But see Cyker's comment, which suggests it runs both filters and then diffs smudged results.)
Is it possible to disable this? Would it be a good idea?
See above—at best you might have a "run only the smudge filter" option (but there is none).
Note that what's in the index is already clean, by definition. Cleaning happens on the transition from work-tree to index; smudging happen on the transition from index to work-tree.
Existing commits are strictly read-only and extracting a commit into the index makes no changes. Hence, while the index contents are clean by definition, if the clean filter itself has changed, they may not match what you would get by re-running the filter.
I would like a solution where autoformat is applied to the staging area, that is only the hunks that were staged. Isn't clean filter an appropriate solution?
This does not work the way you are thinking.
Running git add
does not apply diff hunks to the index copy: running git add
copies the entire work-tree file into the index. The whole thing gets cleaned.
Running git add -p
also does not actually apply diff hunks to the index copy, because it literally can't. Instead, git add -p
extracts the index copy to a temporary file, applies a diff hunk to the temporary file, and then copies the entire temporary file (with applied hunk) into the index, running that through the clean filter. Once again the whole thing gets cleaned—it's just that "the whole thing" is a temporary file built by patching the smudged index copy.
In other words, the index copy of each file is an entity unto itself, independent of the HEAD
commit copy and the work-tree copy. Git starts out, at git checkout
time, by just copying the commit copy of the file directly into the index (no changes, no filters), then copies the index copy of the file into the work-tree (smudge filter). At git add
time, Git runs the clean filter on the work-tree file (or the patched result) and stuffs that into the index.1
1Technically, the index holds not the files themselves, but rather their content hashes. Adding a file consists of writing the file into the repository! The hash ID of the resulting blob object goes into the index. The index entry keeps the blob from being garbage-collected, if the index is the only place the blob is used (if the blob matches some committed blob then it's safe from the Grim Collector).
QUESTION
I've been trying out uncrustify and while I've gotten a lot of mileage out of how configurable it is, I found it occasionally decides to break apart lines in ways I don't agree with.
Some examples:
...ANSWER
Answered 2019-Dec-31 at 22:56It looks like the problem was having ls_code_width
set to true
. Once I set it to false
, uncrustify now seems to try to maintain groupings.
QUESTION
is it possible by using uncrustify to transform this:
...ANSWER
Answered 2019-Aug-02 at 11:54No, this is not one of the options.
Such a thing would be more of a refactoring, than a simple tweak to spacing (which is mostly what this tool does).
There's no open feature request for this at present, either; feel free to create one.
QUESTION
I am trying to execute a Bash script in my build pipeline that is run on a self-hosted agent. The error I am encountering is:
...ANSWER
Answered 2019-Jun-03 at 22:09After about an hour of trial and error, the fix was to explicitly specify the extension in the shell script.
QUESTION
I've been looking at the atom-beautify site and example .jsbeauifyrc, .editorconfig, and uncrustify.cgf files.
I've also reviewed the options for atom-beautify. I know I'm supposed to specify where the config file is located in the atom-beautify settings. I've tried putting a .jsbeautifyrc file, an uncrustify.cfg file, and both files in the same directory I specify in the atom-beautify settings. It doesn't have any effect. The default settings are used. I'd like to make some old C++ code look more uniform for my current project and future projects my group is working on.
- Which file am I supposed to use?
- What must I include in each file?
- Where should this/these file(s) be located?
- How do I specify the path?
- Are there any other changes I need to make that I'm not aware of?
To sum up, I want to use uncrustify from within the Atom editor (using the atom-beautify package) to make my C++ code look nice.
...ANSWER
Answered 2017-Dec-10 at 06:57- Make sure uncrustify is installed on your computer, and accessible from CLI
- In the settings for
atom-beautify
, go under the C++ section and typeuncrustify.cfg
as a Config Path - Place the config file name
uncrustify.cfg
in the root folder - Try beautifying your code, it should be using your config file now
QUESTION
While using uncrustify, I encountered a problem with while loops. If the while loop has no body, a trailing semicolon will get pushed to the next line. On the GitHub and on this website I found no mention of this whatsoever. Is the problem related to forcing one liners in different lines?
The code I tried it with is: (This is also what it should look like in the end)
...ANSWER
Answered 2017-Sep-06 at 14:17With an empty config file this does not happen so this behavior is caused by a option that you added in the config file that you are using (most likely one of the nl_*
options).
Post a link to your file.
Both of this options are causing this behavior:
QUESTION
Where can the indent settings (tab width) be set for uncrustify run by the Atom package atom-beautify (on Windows)? While the package settings offer to specify a path for an uncrustify config file (separately for C and C++), I can't figure out where the default settings come from.
...ANSWER
Answered 2017-May-23 at 16:29The package directory is
- Windows:
C:\Users\\.atom\packages\atom-beautify\src\beautifiers\uncrustify
Uncrustify is run via index.coffee
, resulting in arguments like:
QUESTION
Consider this code:
...ANSWER
Answered 2018-Jun-12 at 16:37Per CDanU's comment, the answer is: don't set indent_continue
.
QUESTION
I need to assign multiline output of command to a variable. I read these two threads:
assigning the output of a command to a variable in a shell script
Capturing multiple line output into a Bash variable
and it works for echo example (multiline commands):
...ANSWER
Answered 2018-Jan-29 at 12:28Why not try:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install uncrustify
Python is an "interpreted high-level programming language for general-purpose programming", for this project it is needed to extend the capabilities of CMake. CMake is a tool that generates build systems (Makefiles, Visual Studio project files, Xcode project files and others).
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page