Skip to content

Commit

Permalink
CCode: Mark problematic code reported by OCLint
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed Jun 18, 2018
1 parent c28953a commit 2fd7555
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/plugins/ccode/testmod_ccode.cpp
Expand Up @@ -58,31 +58,32 @@ CppKeySet percentConfig ()

void testRoundTrip (string const decodedString, string const encodedString = "", CppKeySet config = defaultConfig ())
#ifdef __llvm__
__attribute__ ((annotate ("oclint:suppress[empty if statement]"), annotate ("oclint:suppress[high cyclomatic complexity]"),
annotate ("oclint:suppress[high ncss method]"), annotate ("oclint:suppress[too few branches in switch statement]")))
__attribute__ ((annotate ("oclint:suppress[high cyclomatic complexity]"), annotate ("oclint:suppress[high ncss method]")))
#endif
{
CppKeySet modules{ 0, KS_END };
elektraModulesInit (modules.getKeySet (), NULL);

CppKey parent{ "system/elektra/modules/type", KEY_END };
Plugin * plugin = elektraPluginOpen ("ccode", modules.getKeySet (), config.getKeySet (), *parent);
exit_if_fail (plugin != NULL, "Could not open ccode plugin");
exit_if_fail (plugin != NULL, "Could not open ccode plugin"); //! OCLint (empty if, too few branches switch)

CppKeySet keys{ 20, keyNew ("user/tests/ccode/key", KEY_VALUE, decodedString.c_str (), KEY_END), KS_END };
succeed_if_same (plugin->kdbSet (plugin, keys.getKeySet (), *parent), ELEKTRA_PLUGIN_STATUS_SUCCESS,
"Call of `kdbset` was not successful");
succeed_if_same (plugin->kdbSet (plugin, keys.getKeySet (), *parent), //! OCLint (empty if, too few branches switch)
ELEKTRA_PLUGIN_STATUS_SUCCESS, "Call of `kdbset` was not successful");

if (!encodedString.empty ())
{
CppKey encoded = keys.lookup ("user/tests/ccode/key");
succeed_if_same (encoded.getString (), encodedString, "String not correctly encoded");
succeed_if_same (encoded.getString (), encodedString, //! OCLint (empty if, too few branches switch)
"String not correctly encoded");
}

succeed_if_same (plugin->kdbGet (plugin, keys.getKeySet (), *parent), ELEKTRA_PLUGIN_STATUS_SUCCESS,
"Call of `kdbGet` was not successful");
succeed_if_same (plugin->kdbGet (plugin, keys.getKeySet (), *parent), //! OCLint (empty if, too few branches switch)
ELEKTRA_PLUGIN_STATUS_SUCCESS, "Call of `kdbGet` was not successful");
CppKey decoded = keys.lookup ("user/tests/ccode/key");
succeed_if_same (decoded.getString (), decodedString, "String not correctly decoded");
succeed_if_same (decoded.getString (), decodedString, //! OCLint (empty if, too few branches switch)
"String not correctly decoded");

elektraPluginClose (plugin, 0);
ksDel (modules.release ());
Expand Down

0 comments on commit 2fd7555

Please sign in to comment.