@@ -170,11 +170,14 @@ Thats all nice and well but we also have a Makefile for our project we
170
170
want to check. So let us introduce another feature of our configuration
171
171
syntax: *sections *.
172
172
173
- The line ``[Default] `` specifies that everything below will belong to
174
- the Default section. If nothing is specified, a setting will implicitly
175
- belong to this section.
173
+ The line ``[cli] `` in the ``.coafile `` implies that everything below
174
+ belongs to the special ``cli `` section. You may specify sections when
175
+ you enter the settings via the Command Line Interface (CLI). You will
176
+ soon learn all about them. When you don't specify any sections, the
177
+ settings will implicitly belong to the ``[cli] `` section.
176
178
177
- Let's check the line lengths of our Makefile:
179
+ Next you will see how to specify sections using the command line when
180
+ you are running coala. Let's check the line lengths of our Makefile:
178
181
179
182
::
180
183
@@ -270,24 +273,34 @@ That looks horrible, doesn't it? Let's fix it!
270
273
$ coala -S python.bears=PEP8Bear python.files=\*\*/\*.py \
271
274
--apply-patches --save
272
275
# other output ...
276
+ Executing section cli...
273
277
Executing section python...
274
278
[INFO][11:03:37] Applied 'ApplyPatchAction' for 'PEP8Bear'.
275
279
[INFO][11:03:37] Applied 'ApplyPatchAction' for 'PEP8Bear'.
276
280
277
281
coala would now fix all spacing issues and without bothering you again.
278
282
283
+ .. note ::
284
+
285
+ When you try the above example, you may get a warning, saying that all
286
+ settings in the ``cli `` section are implicitly inherited to all
287
+ other sections (if they do not override their values). It also advises
288
+ us to change the name of that section to avoid unexpected behavior.
289
+ The next section explains what it means and how you can avoid
290
+ it.
291
+
279
292
Setting Inheritance
280
293
-------------------
294
+ Let's first see what inheritance means.
281
295
282
- All settings in the default section are implicitly inherited to all
283
- other sections (if they do not override their values). We can use that
284
- to save a few lines!
296
+ Before proceeding, rename the ``cli `` section in the ``.coafile `` to
297
+ ``all `` (we will soon explain the reason behind this change).
285
298
286
299
Lets add the following section to our ``.coafile ``:
287
300
288
301
::
289
302
290
- [TODOS]
303
+ [all. TODOS]
291
304
bears = KeywordBear
292
305
293
306
And execute ``coala `` with the ``-s `` argument which is the same as
@@ -298,10 +311,26 @@ After the results we've already seen, we'll see a new informational one
298
311
which informs us that we have a TODO in our code.
299
312
300
313
Did you note that we didn't specify which files to check this time? This
301
- is because all settings, including ``files = src/*.c ``, from the Default
302
- section are already available in every other section implicitly. Thus
303
- the default section is a good point to set things like logging and
304
- output settings or specifying a default set of files to check.
314
+ is because all settings, including ``files = src/*.c ``, from the ``all ``
315
+ section (previously called ``cli ``) have been inherited in the new
316
+ ``TODOS `` section that we just added.
317
+
318
+ You can make a section inherit from any previously defined section using
319
+ this syntax:
320
+
321
+ ::
322
+
323
+ [parentSection.childSection]
324
+
325
+ .. note ::
326
+
327
+ ``cli `` is an internally reserved section name. All of its settings
328
+ are implicitly inherited to every other section by default. It is
329
+ because of this implicit inheritance feature that we are adviced to
330
+ rename the ``cli `` section to something else. Doing so will save us
331
+ from having unexpected values of ``cli `` being implicitly inherited
332
+ into our sections. We strongly suggest renaming it.
333
+
305
334
306
335
Ignoring Issues
307
336
---------------
0 commit comments