Skip to content

Perform static analysis over git-tracked files only #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2020

Conversation

OscarShiang
Copy link
Contributor

Cppcheck might fail when trying to check http_parser.c

Since http_parser.c is been ignored from adding into
commit, we don't have to check it in pre-commit stage.

I add CPPCHECK_ignore into scripts/pre-commit.hook
to prevent Cppcheck from checking it.

@jserv
Copy link
Contributor

jserv commented Apr 9, 2020

Instead of changing the options passed to Cppcheck, I would enforce filtered file listing with the aid of Git objects.

@OscarShiang
Copy link
Contributor Author

I add the tracking list generated with command git ls-files *.c to specify on tracked files.

@@ -76,6 +75,7 @@ do
done

# static analysis
git ls-files *.c > $FILE_LIST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to the following:

git ls-tree --full-tree -r --name-only HEAD | \
   grep -v compat | grep -E "\.(c|cc|cpp|h|hh|hpp)\$" | \
   xargs $CPPCHECK $CPPCHECK_OPTS >/dev/null

--suppress=duplicateBreak:http_parser.c \
--suppress=shadowVariable:http_parser.c"
CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses ."
FILE_LIST=.include_file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't set FILE_LIST.

@jserv
Copy link
Contributor

jserv commented Apr 9, 2020

Use git rebase -i to squash the commits. Then, force push.

FILE_LIST=.include_file

CPPCHECK_suppresses="--suppress=missingIncludeSystem"
CPPCHECK_OPTS="-I. --file-list=$FILE_LIST --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Remove --file-list=$FILE_LIST.

@jserv
Copy link
Contributor

jserv commented Apr 9, 2020

The subject can be changed as

Perform static analysis over git-tracked files

@jserv jserv changed the title Avoid checking http_parser.c in pre-commit Perform static analysis over git-tracked files only Apr 9, 2020
@jserv jserv merged commit 6bf04db into sysprog21:master Apr 9, 2020
@OscarShiang
Copy link
Contributor Author

Thanks for your advices!

@OscarShiang OscarShiang deleted the pre_check branch April 9, 2020 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants