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

Possible unused variables/functions in engine code (cppcheck report) #26780

Open
Rubonnek opened this issue Mar 8, 2019 · 5 comments
Open

Possible unused variables/functions in engine code (cppcheck report) #26780

Rubonnek opened this issue Mar 8, 2019 · 5 comments

Comments

@Rubonnek
Copy link
Member

Rubonnek commented Mar 8, 2019

Godot version:

master branch commit 52b7f26

Issue description:

Unusued functions and variables found by cppcheck. Many of these could be false-positives due to binding to Java, Mono, etc.

Steps to reproduce:

  • cd $godot_repo_root
  • cppcheck --enable=all --inconclusive --std=posix --force . 2> cppcheck_godot.log
  • rg -A 1 "\[unu" cppcheck_godot.log > unused_thirdparty_unfiltered.txt
  • And use the following Python 3 script to extract the possibly unused variables and functions:
#!/usr/bin/env python3

fh = open("unused_thirdparty_unfiltered.txt", "r")
mybuf = ""
count = 0
skip_lines = False
for line in fh:
    if line.startswith("thirdparty"):
        skip_lines = True
        continue

    if skip_lines:
        count += 1
        if count == 2:
            skip_lines = False
            count = 0
    else:
        if line != "\n":
            mybuf += line
print(mybuf,end="")

Minimal reproduction project:
unused.txt

@akien-mga akien-mga added this to the 3.2 milestone Mar 8, 2019
@akien-mga akien-mga removed this from the 3.2 milestone Jan 14, 2020
@akien-mga akien-mga changed the title Possible unused variables/functions in engine code Possible unused variables/functions in engine code (cppcheck report) Jan 14, 2020
@KoBeWi
Copy link
Member

KoBeWi commented Dec 4, 2020

The list should be updated, because many of this can be potentially outdated now.

@Rubonnek
Copy link
Member Author

Rubonnek commented Dec 5, 2020

List updated.

@qarmin
Copy link
Contributor

qarmin commented Mar 5, 2021

It is possible to generate graphical cppcheck report with this command

cppcheck -j6  -ithirdparty -i3rdparty -itests -itest -itoolchain -itools  --enable=all --force --output-file=cppcheck.xml --xml --xml-version=2 .;cppcheck-htmlreport --source-dir=. --title=project --file=cppcheck.xml --report-dir=report;xdg-open report/index.html

Looks that unused functions require to remove -j6 from command(check can't work when checking parts of program in several threads)

Generated report for bd9799e - report.zip

Unread variables, redundant assignement, unusedStructMember, redundantInitialization and unused private function should be useful for this issue
Zrzut ekranu z 2021-03-05 10-40-10
This allow to click at report to see code with place where error exists
Zrzut ekranu z 2021-03-05 10-44-10

@KoBeWi
Copy link
Member

KoBeWi commented Jan 19, 2023

Probably worth refreshing this. A big PR was recently merged and the codebase changed quite a lot too. I tried using cppcheck myself, but it just freezes around 12% :/

@Rubonnek
Copy link
Member Author

Rubonnek commented Jan 20, 2023

Here's a report against commit 9f74f0f. Generated with cppcheck version 2.9.3.

I've also opened #71767 to track the same issue but on the 3.x branch and I've also attached a report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants