<commit_before>// csamisc_anonymousnamespaceinheader.t.cpp                           -*-C++-*-
// -----------------------------------------------------------------------------
// Copyright 2011 <NAME> http://www.dietmar-kuehl.de              
// Distributed under the Boost Software License, Version 1.0. (See file  
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).     
// -----------------------------------------------------------------------------

#include <csabase_analyser.h>
#include <csabase_location.h>
#include <csabase_registercheck.h>
#ident "$Id$"

// -----------------------------------------------------------------------------

static std::string const check_name("anon-namespace");

static void
anonymous_namespace_in_header(cool::csabase::Analyser& analyser, clang::NamespaceDecl const* decl)
{
    if (decl->isAnonymousNamespace()
        && analyser.get_location(decl).file() != analyser.toplevel())
    {
        analyser.report(decl, check_name, "ANS01",
                "Anonymous namespace in header");
    }
}

// -----------------------------------------------------------------------------

static cool::csabase::RegisterCheck check(check_name, &anonymous_namespace_in_header);<commit_msg>Check should be for component header, not not toplevel.<commit_after>// csamisc_anonymousnamespaceinheader.t.cpp                           -*-C++-*-
// -----------------------------------------------------------------------------
// Copyright 2011 <NAME> http://www.dietmar-kuehl.de              
// Distributed under the Boost Software License, Version 1.0. (See file  
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).     
// -----------------------------------------------------------------------------

#include <csabase_analyser.h>
#include <csabase_debug.h>
#include <csabase_location.h>
#include <csabase_registercheck.h>
#ident "$Id$"

// -----------------------------------------------------------------------------

static std::string const check_name("anon-namespace");

static void anonymous_namespace_in_header(cool::csabase::Analyser& analyser,
                                          clang::NamespaceDecl const* decl)
{
    if (decl->isAnonymousNamespace() && analyser.is_component_header(decl)) {
        analyser.report(decl, check_name, "ANS01",
                "Anonymous namespace in header", true);
    }
}

// -----------------------------------------------------------------------------

static cool::csabase::RegisterCheck check(check_name, &anonymous_namespace_in_header);
{'fraction_non_alphanumeric': 0.3423317683881064, 'fraction_numerical': 0.009389671361502348, 'mean_word_length': 1.35451197053407, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4329882', 'n_tokens_mistral': 630, 'n_tokens_neox': 611, 'n_words': 121}