Skip to content
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

[fix][clang-tidy] Fix env var replace for extra args #4033

Merged

Conversation

Jonah-E
Copy link
Contributor

@Jonah-E Jonah-E commented Oct 9, 2023

Running codechecker and giving extra arguments for clang-tidy containing environmental variables fails. This issue seems to stem from that env.replace_env_var is use without an argument in analyzer/codechecker_analyzer/analyzers/clangtidy/analyzer.py. This should fix it.

To reproduce the issue, run the following:
With the file main.c containing:

#include <stdio.h>

int main(void){
  int i = BUILDVAR;
  printf("Hello world!\n\tBUILDVAR=%d\n", i  );
  return 0;
}

and the file `.clangtidy_extra_flags.txt containing:

--extra-arg="-DBUILDVAR=$(MY_ENV_VAR)"
  1. Set the environmental varible MY_ENV_VAR
export MY_ENV_VAR=55
  1. Run the following command
CodeChecker check -b "gcc main.c -DBUILDVAR=$MY_ENV_VAR" --tidyargs .clangtidy_extra_flags.txt

This should fail with TypeError: sequence item 1: expected str instance, function found

@Szelethus Szelethus added bugfix 🔨 clang-tidy 🐉 clang-tidy is a clang-based C++ “linter” tool. labels Oct 9, 2023
@Szelethus Szelethus added this to the release 6.23.0 milestone Oct 9, 2023
@bruntib bruntib merged commit bd9c2ff into Ericsson:master Oct 10, 2023
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix 🔨 clang-tidy 🐉 clang-tidy is a clang-based C++ “linter” tool.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants