'CLang tidy does not recognize namespace keyword and interprets it as a variable

I am ramping up a Platform IO project. Within there I am using clang-tidy for different checks (see documentation for PIO clang-tidy here).

Given the folder structure

- .
-- include
-- src

I placed a header file in the include folder, called ISomeInterface.h The content looks like this:

#pragma once

namespace some_namespace { // interface declaration
}

When I run pio check (invokes clang-tidy) I get the warning

variable 'some_namespace' is non-const and globally accessible, consider making it const  [cppcoreguidelines-avoid-non-const-global-variables]

The Question is: Why is CLang not recognizing the namespace keyword? I found a possible solution here SO Thread that states

can't use clang-tidy directly on header files. Instead i have to check the cpp file and have to add -header-filter=.* to also check the headers

But this did not work for me :(



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source