mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 15:17:29 +00:00
TODO: solidify plans for code formatting
This commit is contained in:
parent
6aa58d51be
commit
6dd8465948
102
TODO
102
TODO
@ -3,8 +3,9 @@ Next
|
|||||||
====
|
====
|
||||||
|
|
||||||
In order:
|
In order:
|
||||||
* PointerHolder -> shared_ptr
|
* PR #661 (overloaded getters from m-holger)
|
||||||
* code formatting
|
* code formatting
|
||||||
|
* PointerHolder -> shared_ptr
|
||||||
* cmake
|
* cmake
|
||||||
* ABI including --json default is latest
|
* ABI including --json default is latest
|
||||||
* json v2
|
* json v2
|
||||||
@ -34,62 +35,69 @@ Soon: Break ground on "Document-level work"
|
|||||||
Code Formatting
|
Code Formatting
|
||||||
===============
|
===============
|
||||||
|
|
||||||
It would be good to have automatic code formatting to make the code
|
Use clang-format-15.
|
||||||
more consistent and to make it easier for contributors. We would do a
|
|
||||||
big commit to bring everything up to spec. Things to keep in mind:
|
|
||||||
|
|
||||||
* clang-format looks promising but is a bit of a moving target; need
|
* Put a .clang-format at the top of the repository -- see below for content.
|
||||||
to see if its output has been stable over the past few releases
|
* Reformat all files:
|
||||||
since the first one that can produce code the way I like it. I may
|
|
||||||
have to require a minimum clang-format version.
|
|
||||||
|
|
||||||
* Ideas here aim for something similar to rust's defaults but with
|
for i in **/*.cc **/*.c **/*.h **/*.hh; do
|
||||||
adjustments to meet my existing style and preferences:
|
clang-format < $i >| $i.new && mv $i.new $i
|
||||||
|
done
|
||||||
|
|
||||||
* 80 columns
|
* Carefully inspect the diff. There are some places where a comment to
|
||||||
|
force a line break might be in order.
|
||||||
|
|
||||||
* 4-space indent (no tabs)
|
* Update README-maintainer about formatting. Mention
|
||||||
|
|
||||||
* Compact braces. While this is a big departure from the past and
|
|
||||||
will create many changes, I have become accustomed to this style
|
|
||||||
and use it across my projects in other languages these days.
|
|
||||||
|
|
||||||
* No "bin packing" -- if arguments (constructor initializers,
|
|
||||||
function arguments, etc.) don't fit on one line, do one argument
|
|
||||||
per line
|
|
||||||
|
|
||||||
* With the exception of short lambdas, no block constructs can be
|
|
||||||
collapsed to a single line.
|
|
||||||
|
|
||||||
* Braces are mandatory for all control constructs (no if, while,
|
|
||||||
etc. without braces)
|
|
||||||
|
|
||||||
* Space after control constructs
|
|
||||||
|
|
||||||
* Try to get emacs c-style to match as closely as possible
|
|
||||||
|
|
||||||
* Consider blame.ignoreRevsFile if it seems to help
|
|
||||||
|
|
||||||
* See also https://bestpractices.coreinfrastructure.org/en
|
|
||||||
|
|
||||||
* QTC::TC first two arguments have to be lexically on one line. If the
|
|
||||||
code formatter breaks this, some QTC calls may have to be surrounded by
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
or qtest may have to be made more flexible unless the formatter has
|
as well as the use of a comment to force a line break.
|
||||||
some rules about some places where lines shouldn't be broken.
|
|
||||||
|
|
||||||
* auto_* files from generate_auto_job should be exempt from
|
Tentative .clang-format:
|
||||||
formatting.
|
|
||||||
|
|
||||||
Ideally it should be possible to run formatting in CI so that pull
|
```
|
||||||
requests have to be properly formatting, but if not, there needs to be
|
---
|
||||||
a `make format` similar to `make spell` that I could apply after
|
Language: Cpp
|
||||||
merging contributions and from time to time.
|
BasedOnStyle: LLVM
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
AlignEscapedNewlines: DontAlign
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
DeriveLineEnding: false
|
||||||
|
PackConstructorInitializers: Never
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^["<](qpdf)/'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
IndentCaseBlocks: true
|
||||||
|
IndentWidth: 4
|
||||||
|
InsertTrailingCommas: Wrapped
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
PointerAlignment: Left
|
||||||
|
```
|
||||||
|
|
||||||
A .clang-format file can be created at the top of the repository.
|
Remaining work:
|
||||||
|
|
||||||
|
* Try to get emacs c-style to match as closely as possible
|
||||||
|
* Consider blame.ignoreRevsFile if it seems to help
|
||||||
|
* Add a `make format` similar to `make spell` (or whatever this ends
|
||||||
|
up being with cmake)
|
||||||
|
* Consider a github action to check formatting. I don't want
|
||||||
|
formatting failures to prevent all the tests from being run.
|
||||||
|
Alternatively, add running `make format` as a release preparation
|
||||||
|
check like `make spell`.
|
||||||
|
|
||||||
Output JSON v2
|
Output JSON v2
|
||||||
==============
|
==============
|
||||||
@ -782,6 +790,8 @@ directory or that are otherwise not publicly accessible. This includes
|
|||||||
things sent to me by email that are specifically not public. Even so,
|
things sent to me by email that are specifically not public. Even so,
|
||||||
I find it useful to make reference to them in this list.
|
I find it useful to make reference to them in this list.
|
||||||
|
|
||||||
|
* Look at https://bestpractices.coreinfrastructure.org/en
|
||||||
|
|
||||||
* Get rid of remaining assert() calls from non-test code.
|
* Get rid of remaining assert() calls from non-test code.
|
||||||
|
|
||||||
* Consider updating the fuzzer with code that exercises
|
* Consider updating the fuzzer with code that exercises
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// This file is #included in other source files.
|
||||||
|
|
||||||
#ifndef __BITS_CC__
|
#ifndef __BITS_CC__
|
||||||
#define __BITS_CC__
|
#define __BITS_CC__
|
||||||
|
Loading…
Reference in New Issue
Block a user