File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -572,6 +572,34 @@ The usage of the suppressions file is as follows:
572572
573573 cppcheck --suppress-xml=suppressions.xml src/
574574
575+ ### The ` <hash> ` element
576+
577+ Cppcheck calculates a unique ID for each error, called the hash. The hash depends on the code that
578+ is related to the error, not on where that code is located. This means that the hash for an error
579+ stays the same even when unrelated code elsewhere in the file is added, removed or moved, shifting
580+ the line numbers around. The hash only changes if the related code itself is modified.
581+
582+ This makes hash-based suppressions more robust than line-based suppressions: once you have
583+ reviewed and suppressed a specific warning, the suppression keeps working even after the file is
584+ edited, as long as the offending code is not changed.
585+
586+ The hash for an error is included as the ` hash ` attribute in the [ XML output] ( #the-error-element ) .
587+ You can copy that value into a ` <hash> ` element in a suppressions XML file:
588+
589+ <?xml version="1.0"?>
590+ <suppressions>
591+ <suppress>
592+ <id>uninitvar</id>
593+ <fileName>src/file1.c</fileName>
594+ <hash>12345678</hash>
595+ </suppress>
596+ </suppressions>
597+
598+ A suppression can use ` <hash> ` on its own, without ` <id> ` , to suppress a specific error regardless
599+ of its id. It is also possible to combine ` <hash> ` with ` <id> ` , ` <fileName> ` , ` <lineNumber> ` and
600+ ` <symbolName> ` ; when several of these are specified, all of them must match for the suppression to
601+ apply.
602+
575603## Inline suppressions
576604
577605Suppressions can also be added directly in the code by adding comments that contain special keywords.
Original file line number Diff line number Diff line change @@ -573,6 +573,34 @@ The usage of the suppressions file is as follows:
573573
574574 cppcheck --suppress-xml=suppressions.xml src/
575575
576+ ### The ` <hash> ` element
577+
578+ Cppcheck calculates a unique ID for each error, called the hash. The hash depends on the code that
579+ is related to the error, not on where that code is located. This means that the hash for an error
580+ stays the same even when unrelated code elsewhere in the file is added, removed or moved, shifting
581+ the line numbers around. The hash only changes if the related code itself is modified.
582+
583+ This makes hash-based suppressions more robust than line-based suppressions: once you have
584+ reviewed and suppressed a specific warning, the suppression keeps working even after the file is
585+ edited, as long as the offending code is not changed.
586+
587+ The hash for an error is included as the ` hash ` attribute in the [ XML output] ( #the-error-element ) .
588+ You can copy that value into a ` <hash> ` element in a suppressions XML file:
589+
590+ <?xml version="1.0"?>
591+ <suppressions>
592+ <suppress>
593+ <id>uninitvar</id>
594+ <fileName>src/file1.c</fileName>
595+ <hash>12345678</hash>
596+ </suppress>
597+ </suppressions>
598+
599+ A suppression can use ` <hash> ` on its own, without ` <id> ` , to suppress a specific error regardless
600+ of its id. It is also possible to combine ` <hash> ` with ` <id> ` , ` <fileName> ` , ` <lineNumber> ` and
601+ ` <symbolName> ` ; when several of these are specified, all of them must match for the suppression to
602+ apply.
603+
576604## Inline suppressions
577605
578606Suppressions can also be added directly in the code by adding comments that contain special keywords.
You can’t perform that action at this time.
0 commit comments