AtomLinter / linter-cpplint

Linter plugin for c++, using cpplint
https://atom.io/packages/linter-cpplint
MIT License
6 stars 5 forks source link

Not linting header files #25

Open maasha opened 8 years ago

maasha commented 8 years ago

It used to work at some point, but after reinstalling Atom and upgrading linter etc, header files are not linted. My header files have .h suffix, and I didn't touch the default extensions.

Atom 1.1.0 linter 1.10.0 linter-cpplint 1.0.0

Arcanemagus commented 8 years ago

Looks like the grammarScopes need to be expanded to include the scope header files identify as, a PR would be welcome!

JayThomason commented 8 years ago

I looked into this because I seemed to be having the same problem. It turns out that atom is detecting C++ header files as C headers (see https://github.com/atom/atom/issues/4156).

The easiest fix for me was forcing atom to recognize .h files as C++ instead of C by adding to ~/.atom/config.cson

  core:
    customFileTypes:
      "source.cpp": [
        "h"
      ]

This could also be fixed by adding "source.c" to the grammarScopes, however considering that the problem is not caused by linter-cpplint I don't like that solution. The above solution will also give proper C++ syntax highlighting, etc.

Arcanemagus commented 8 years ago

C++ style header files should actually have a .hpp extension, .h files are C header files. That being said, a lot of projects name them improperly so the choices are either overriding the scope for .h files like you mention, or marking this package as supporting source.c, which can lead to other issues as it would then try to lint C code...

JayThomason commented 8 years ago

I agree that it would be nice if C++ header files used the .hpp extension but, as you said, many projects use .h files for C++ headers. For example even the Google C++ style guide advocates usage of .h for C++ header files.

While not optimal, the reason that I suggested the workaround above is because this problem should be fixed by whatever system is detecting the file type, instead of plugins which rely on that functionality.

The other workaround is to change the file type in atom on a file by file basis using the grammar selector.

keplersj commented 8 years ago

@Arcanemagus This could be fixed by making the C syntax valid on this linter, and checking that the file being linted ends with a header extension.

Or we could convince the core Atom team to distinguish C source files from C header files...