Comments (16)
With files foo.A
, bar.b
, testCpplint.cxx
and
CPP_CPPLINT_FILE_EXTENSIONS: [".A", ".b", ".c", ".C", ".h", ".cxx", ".cpp"]
I get the following:
+----MATCHING LINTERS-----+--------------------------+----------------+------------+
| Descriptor | Linter | Criteria | Matching files | Format/Fix |
+------------+------------+--------------------------+----------------+------------+
| CPP | cpplint | .A|.b|.c|.C|.h|.cxx|.cpp | 3 | no |
+------------+------------+--------------------------+----------------+------------+
...
[cpplint] bar.b
[cpplint] foo.A
[cpplint] testCpplint.cxx
...
--Error detail:
Ignoring bar.b; not a valid file name (hpp, c++, hh, cuh, c, cc, cu, h, hxx, cxx, cpp, h++)
Ignoring foo.A; not a valid file name (hpp, c++, hh, cuh, c, cc, cu, h, hxx, cxx, cpp, h++)
testCpplint.cxx:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
Done processing bar.b
Done processing foo.A
Done processing testCpplint.cxx
Again, locally cpplint works as expected, when provided with the --extensions
argument.
That makes me suspect that the following is happening:
-
MegaLinter considers
CPP_CPPLINT_FILE_EXTENSIONS
only for collecting files to be checked with cpplint but it does not pass those extensions in the--extensions=...
argument of thecpplint
command and therefore cpplint always only checks files with prefixes from the default list of extensions, i.e. hpp, c++, hh, cuh, c, cc, cu, h, hxx, cxx, cpp, h++. Since it already includes"c"
, it always works for linting.c
files. -
MegaLinter prints a linter's output only when it exits with a non-zero code. The "not a valid file name" error does not trigger a non-zero exit code of the
cpplint
command, therefore it is not reported when it is the only kind of error.
from megalinter.
@vkucera probably but in case there are other constraints (FILTER_REGEX_EXCLUDE, etc....) , that way we'll be sure to send only the file extensions related to the list of files, not more extensions that are not matching files in the repo :)
PR on the way
from megalinter.
Interesting report! I clearly see that something isn't going quite right.
from megalinter.
Could you tell us what version of Megalinter it is running, and is it locally, or on CI (if so, is it GitHub Actions?). Is it using a flavor, if yes, which one? If you are locally, on what platform are you on? Is your file system case-sensitive? I know for example that on windows, NTFS is not case-sensitive, but case-preserving. This case of having a file with the same name, except the case of the extension would probably not work on windows.
There was some changes recently where we are starting to have a c and a cpp flavor in order to have more linters in that category, and having clang-format. But these aren't out yet. It might also help us to know if the same thing happens with the beta versions too (that are the main branch)
from megalinter.
Hi @echoix , thanks for your quick feedback.
v7.5.0, GitHub action, no flavour, runs-on: ubuntu-latest
.
Hope it helps.
from megalinter.
To try to discriminate between a problem with file handling or extension handling, a useful case to check would be
file1.c
andfile2.C
: varies the extension, without having the same name.Files3.C
,files3.c
,files3.C
,files3.c
folder1/file4.c
andfolder2/file4.C
from megalinter.
Hi @echoix , thanks for your quick feedback.
v7.5.0, GitHub action, no flavour,
runs-on: ubuntu-latest
.Hope it helps.
Maybe try the beta flavor to make sure it isn't something fixed in another version :s
from megalinter.
To try to discriminate between a problem with file handling or extension handling, a useful case to check would be
1. `file1.c` and `file2.C` : varies the extension, without having the same name. 2. `Files3.C`, `files3.c`, `files3.C`, `files3.c` 3. `folder1/file4.c` and `folder2/file4.C`
The name does not seem to matter. I created the testCpplint
files only to provide a MWE. I see the same issue with many other files. The only factor that makes a difference is the extension upper case. I haven't tried other extensions though.
from megalinter.
Hi @echoix , thanks for your quick feedback.
v7.5.0, GitHub action, no flavour,runs-on: ubuntu-latest
.
Hope it helps.Maybe try the beta flavor to make sure it isn't something fixed in another version :s
Will try.
from megalinter.
Hi @echoix , thanks for your quick feedback.
v7.5.0, GitHub action, no flavour,runs-on: ubuntu-latest
.
Hope it helps.Maybe try the beta flavor to make sure it isn't something fixed in another version :s
Will try.
The beta version (55f2d6f) behaves the same.
from megalinter.
Ok thanks a lot! I won't investigate tonight, but it's pretty descriptive!
from megalinter.
@vkucera your analysis seems right ! :)
- cpplint seems to ask for file extensions whereas we already send it a list of files
- it does notreturn a status code > 0 when it receives options it can not handle... that's strange
We can adapt MegaLinter to such behavior, probably by defining a python class to override some methods, but it is quite uncommon compared to many other linters ;)
from megalinter.
@nvuillam , if you can confirm that MegaLinter indeed does not call the cpplint
command with the --extensions=...
option, then simply adding it would fix the issue.
I guess it should not be complicated to parse CPP_CPPLINT_FILE_EXTENSIONS
and provide the formatted list of extensions to the cpplint
command.
from megalinter.
If you can do this when .mega-linter.yml
is parsed, it will work just fine.
CPP_CPPLINT_ARGUMENTS = "--extensions=" + ",".join(e[1:] for e in CPP_CPPLINT_FILE_EXTENSIONS)
Of course provided that the potential CPP_CPPLINT_ARGUMENTS
in .mega-linter.yml
is included properly as well.
from megalinter.
@vkucera why not just listing the extensions from the list of files sent as arguments and dynamically create --extensions= argument ? ^^
from megalinter.
@vkucera why not just listing the extensions from the list of files sent as arguments and dynamically create --extensions= argument ? ^^
Which is equivalent to creating the --extensions
argument directly from CPP_CPPLINT_FILE_EXTENSIONS
, isn't it?
from megalinter.
Related Issues (20)
- Devskim config ignored instead crawl-archives enabled by default HOT 1
- VSCODE error HOT 2
- Can EXTENDS be set in env? HOT 2
- TFLint - deprecated argument in ".tflint.hcl" HOT 6
- Action "Auto-Update Linters" is failing HOT 19
- Dependency "ip" needs to be replaced HOT 2
- Dependency Dashboard
- Add conftest integration HOT 2
- False negatives in v8r when validating mega-linter.yml HOT 4
- golangci-lint linter fails, as my go.mod has 1.22, but Alpine 3.19 has 1.21 HOT 4
- [Bug] Github Actions - 404 Network Errors Encountered with MegaLinter URLs HOT 3
- gherkin-linter in c_cpp flavor HOT 1
- Set env var via PRE_COMMAND HOT 4
- Making outbound network requests by default is very surprising behavior HOT 1
- Detect smallest flavour to improve performance? HOT 5
- Request new MegaLinter flavor
- Kotlin Detekt cli_lint_mode= list_of_files support HOT 2
- lightning-flow-scanner fails for salesforce flavor due to sf cli reporting update availablee HOT 1
- AzureCommentReporter.py permission issues on Azure DevOps HOT 1
- MEGALINTER_CONFIG Variable ignored Gitlab CI HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from megalinter.