Debian Codegraph @

.github/CONTRIBUTING.md

raw symbols SCIP
1 # Contribution Guidelines
2
3 Thank you for your interest in contributing to this project! What began as an exercise to explore the exciting features
4 of C++11 has evolved into a [widely-used](https://json.nlohmann.me/home/customers/) JSON library. I truly appreciate all
5 the contributions from the community, whether it's proposing features, identifying bugs, or fixing mistakes! To ensure
6 that our collaboration is efficient and effective, please follow these guidelines.
7
8 Feel free to discuss or suggest improvements to this document
9 [by submitting a pull request](https://github.com/nlohmann/json/edit/develop/.github/CONTRIBUTING.md).
10
11 ## Ways to Contribute
12
13 There are multiple ways to contribute.
14
15 ### Reporting an issue
16
17 Please [create an issue](https://github.com/nlohmann/json/issues/new/choose), assuming one does not already exist, and
18 describe your concern. Note you need a [GitHub account](https://github.com/signup/free) for this.
19
20 Clearly describe the issue:
21
22 - If it is a bug, please describe how to **reproduce** it. If possible, attach a _complete example_ which demonstrates
23 the error. Please also state what you **expected** to happen instead of the error.
24 - If you propose a change or addition, try to give an **example** how the improved code could look like or how to use
25 it.
26 - If you found a compilation error, please tell us which **compiler** (version and operating system) you used and paste
27 the (relevant part of) the error messages to the ticket.
28
29 Please stick to the provided issue template
30 [bug report](https://github.com/nlohmann/json/blob/develop/.github/ISSUE_TEMPLATE/bug.yaml) if possible.
31
32 ### Reporting a security vulnerability
33
34 You can report a security vulnerability according to our
35 [security policy](https://github.com/nlohmann/json/security/policy).
36
37 ### Discussing a new feature
38
39 For questions, feature or support requests, please
40 [open a discussion](https://github.com/nlohmann/json/discussions/new). If you find a proposed answer satisfactory,
41 please use the "Mark as answer" button to make it easier for readers to see what helped and for the community to filter
42 for open questions.
43
44 ### Proposing a fix or an improvement
45
46 Join an ongoing discussion or comment on an existing issue before starting to code. This can help to avoid duplicate
47 efforts or other frustration during the later review.
48
49 Create a [pull request](https://github.com/nlohmann/json/pulls?q=sort%3Aupdated-desc+is%3Apr+is%3Aopen) against the
50 `develop` branch and follow the pull request template. In particular,
51
52 - describe the changes in detail, both the what and why,
53 - reference existing issues where applicable,
54 - add tests to maintain 100% test coverage,
55 - update the documentation as needed, and
56 - ensure the source code is amalgamated.
57
58 We describe all points in detail below.
59
60 All contributions (including pull requests) must agree to the
61 [Developer Certificate of Origin (DCO) version 1.1](https://developercertificate.org). This is exactly the same one
62 created and used by the Linux kernel developers and posted on http://developercertificate.org/. This is a developer's
63 certification that he or she has the right to submit the patch for inclusion into the project.
64
65 ## How to...
66
67 ### Describe your changes
68
69 This library is primarily maintained as a spare-time project. As such, I can not make any guarantee how quickly changes
70 are merged and released. Therefore, it is very important to make the review as smooth as possible by explaining not only
71 _what_ you changed, but _why_. This rationale can be very valuable down the road when improvements or bugs are discussed
72 years later.
73
74 ### Reference existing issues
75
76 [Link a pull request to an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue)
77 to clarify that a fix is forthcoming and which issue can be closed after merging. Only few cases (e.g., fixing typos)
78 don’t require prior discussions.
79
80 ### Write tests
81
82 The library has an extensive test suite that currently covers [100 %](https://coveralls.io/github/nlohmann/json) of the
83 library's code. These test are crucial to maintain API stability and give future contributors confidence that they do
84 not accidentally break things. As Titus Winters aptly put it:
85
86 > If you liked it, you should have put a test on it.
87
88 #### Run the tests
89
90 First, ensure the test suite runs before making any changes:
91
92 ```sh
93 $ cmake -S. -B build
94 $ cmake --build build -j 10
95 $ ctest --test-dir build -j 10
96 ```
97
98 The test suite should report:
99
100 ```
101 100% tests passed, 0 tests failed out of 98
102 ```
103
104 #### Add tests
105
106 The tests are located in [`tests/src/unit-*.cpp`](https://github.com/nlohmann/json/tree/develop/tests/src) and contain
107 [doctest assertions](https://github.com/doctest/doctest/blob/master/doc/markdown/assertions.md) like `CHECK`. The tests
108 are structured along the features of the library or the nature of the tests. Usually, it should be clear from the
109 context which existing file needs to be extended, and only very few cases require creating new test files.
110
111 When fixing a bug, edit `unit-regression2.cpp` and add a section referencing the fixed issue.
112
113 #### Exceptions
114
115 When you test exceptions, please use `CHECK_THROWS_WITH_AS` which also takes the `what()` argument of the thrown
116 exception into account.
117
118 #### Coverage
119
120 If test coverage decreases, an automatic warning comment will be posted on the pull request. You can access a code
121 coverage report as artifact to the “Ubuntu” workflow.
122
123 ### Update the documentation
124
125 The [main documentation](https://json.nlohmann.me) of the library is generated from the files
126 [`docs/mkdocs/docs`](https://github.com/nlohmann/json/blob/develop/docs/mkdocs/docs). This folder contains dedicated
127 pages for [certain features](https://github.com/nlohmann/json/tree/develop/docs/mkdocs/docs/features), a list of
128 [all exceptions](https://github.com/nlohmann/json/blob/develop/docs/mkdocs/docs/home/exceptions.md), and an
129 [extensive API documentation](https://github.com/nlohmann/json/tree/develop/docs/mkdocs/docs/api) with details on every
130 public API function.
131
132 Build the documentation locally using:
133
134 ```shell
135 make install_venv -C docs/mkdocs
136 make serve -C docs/mkdocs
137 ```
138
139 The documentation will then available at <http://127.0.0.1:8000/>. See the documentation of
140 [mkdocs](https://www.mkdocs.org) and [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for more
141 information.
142
143 ### Amalgamate the source code
144
145 The single-header files
146 [`single_include/nlohmann/json.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json.hpp) and
147 [`single_include/nlohmann/json_fwd.hpp`](https://github.com/nlohmann/json/blob/develop/single_include/nlohmann/json_fwd.hpp)
148 are **generated** from the source files in the
149 [`include/nlohmann` directory](https://github.com/nlohmann/json/tree/develop/include/nlohmann). **Do not** edit the
150 files directly; instead, modify the include/nlohmann sources and regenerate the files by executing:
151
152 ```shell
153 make amalgamate
154 ```
155
156 ## Recommended documentation
157
158 - The library’s [README file](https://github.com/nlohmann/json/blob/master/README.md) is an excellent starting point to
159 understand its functionality.
160 - The [documentation page](https://json.nlohmann.me) is the reference documentation of the library.
161 - [RFC 8259](https://datatracker.ietf.org/doc/html/rfc8259) is the reference for the JavaScript Object Notation (JSON)
162 Data Interchange Format.
163
164 ## Please don't...
165
166 Certain contributions are not helpful.
167
168 ### Break the public API
169
170 We take pride in the library being used by
171 [numerous customers across various industries](https://json.nlohmann.me/home/customers/). They all rely on the
172 guarantees provided by [semantic versioning](https://semver.org). Please do not change the library such that the public
173 API of the 3.x.y version is broken. This includes:
174
175 - Changing function signatures (altering parameter types, return types, number of parameters) or changing the const-ness
176 of member functions.
177 - Removing functions.
178 - Renaming functions or classes.
179 - Changing exception handling.
180 - Changing exception ids.
181 - Changing access specifiers.
182 - Changing default arguments.
183
184 Although these guidelines may seem restrictive, they are essential for maintaining the library’s utility.
185
186 Breaking changes may be introduced when they are guarded with a feature macro such as
187 [`JSON_USE_IMPLICIT_CONVERSIONS`](https://json.nlohmann.me/api/macros/json_use_implicit_conversions/) which allows to
188 selectively change the behavior of the library. In next steps, the current behavior can then be deprecated. Using
189 feature macros then allows users to test their code against the library in the next major release.
190
191 ### Break C++11 language conformance
192
193 This library is designed to work with C++11 and later. This means that any
194 [supported C++11 compiler](https://github.com/nlohmann/json/blob/master/README.md#supported-compilers) should compile
195 the library without problems. Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual
196 Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support.
197
198 Please do not add features that do not work with the mentioned supported compilers. Please guard features from C++14 and
199 later against the respective [`JSON_HAS_CPP_14`](https://json.nlohmann.me/api/macros/json_has_cpp_11/) macros.
200
201 ### Break JSON conformance
202
203 Please refrain from proposing changes that would **break [JSON](https://datatracker.ietf.org/doc/html/rfc8259)
204 conformance**. If you propose a conformant extension of JSON to be supported by the library, please motivate this
205 extension.
206
207 ## Wanted
208
209 The following areas really need contribution and are always welcomed:
210
211 - Extending the **continuous integration** toward more exotic compilers such as Android NDK, Intel's Compiler, or the
212 bleeding-edge versions Clang.
213 - Improving the efficiency of the **JSON parser**. The current parser is implemented as a naive recursive descent parser
214 with hand coded string handling. More sophisticated approaches like LALR parsers would be really appreciated. That
215 said, parser generators like Bison or ANTLR do not play nice with single-header files -- I really would like to keep
216 the parser inside the `json.hpp` header, and I am not aware of approaches similar to [`re2c`](http://re2c.org) for
217 parsing.
218 - Extending and updating existing **benchmarks** to include (the most recent version of) this library. Though efficiency
219 is not everything, speed and memory consumption are very important characteristics for C++ developers, so having
220 proper comparisons would be interesting.
221
222 We look forward to your contributions and collaboration to enhance the library!