Page MenuHomePhabricator

[LINTER] Prevent including a source file
ClosedPublic

Authored by Fabien on Jun 13 2019, 15:50.

Details

Summary

This linter detects the #include of *.c ,*.cc or *.cpp file.

Depends on D3333

Test Plan

Modify src/init.cpp to include a *.c, *.cc or *.cpp file.

arc lint -- src/init.cpp

Check the linter detects the inclusion and thrown an error.

Diff Detail

Repository
rABC Bitcoin ABC
Branch
linter_include_cpp
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 6339
Build 10725: Bitcoin ABC Buildbot (legacy)
Build 10724: arc lint + arc unit

Event Timeline

deadalnix requested changes to this revision.Jun 13 2019, 22:24

This should also detect the inclusion of a .c .

This revision now requires changes to proceed.Jun 13 2019, 22:24

Has this error actually happened in the wild ? Also, do we need a new linter for each thing that can go wrong with includes ? It seems like one should be enough.

arcanist/linter/IncludeSourceLinter.php
29 ↗(On Diff #9400)

It seems like this is completely redundant code.

57 ↗(On Diff #9400)

???

@deadalnix Yes this error did appear:
https://reviews.bitcoinabc.org/D3283?id=9308#inline-20242

I considered having a single linter, but as long as there is no performance penalty (arc linting all takes < 0.5s) I prefer leaving them separated.
It makes the error output more specific (the short error code) and allows for varying file filters individually.

Check for *.c inclusion.
Fix indent.

Fabien edited the test plan for this revision. (Show Details)
.arclint
93

You probably want to check C files

Add an exception for the crypto/ctaes/ctaes.c include in crypto.aes.cpp.

This revision is now accepted and ready to land.Jun 22 2019, 02:11
This revision was automatically updated to reflect the committed changes.