-
Notifications
You must be signed in to change notification settings - Fork 1
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
Критерий -- поиск goto
(часть 1)
#18
Comments
Надо бы проверить, что данной проверки ещё нет в oclint |
Такая проверка действительно уже есть в OCLint. jcdkiki@pc:~/code/oclint_extensions/examples$ ./test-gcc.sh ex-goto
OCLint Report
Summary: TotalFiles=1 FilesWithViolations=1 P1=0 P2=0 P3=2
/home/jcdkiki/code/oclint_extensions/examples/ex-goto/main.cpp:9:14: goto statement [basic|P3]
/home/jcdkiki/code/oclint_extensions/examples/ex-goto/main.cpp:6:2: short variable name [naming|P3] Length of variable name `x` is 1, which is shorter than the threshold of 3
[OCLint (https://oclint.org) v22.02] ex-goto/main.cpp: #include <iostream>
using namespace std;
int main()
{
int x;
cin >> x;
if (x != 2) goto failed;
cout << "Congrats! You typed 2!" << endl;
failed:
return 0;
} Критерий называется |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
goto
-- в общем случае плохо и используется не по назначению. Нужно кидать предупреждение при использованииgoto
Пример плохо кода:
Как должно быть:
The text was updated successfully, but these errors were encountered: