Skip to content

Test Static Analysis Action from fork#7

Open
JacobDTest wants to merge 13 commits into
JacobDomagala:mainfrom
JacobDTest:test-branch-fork
Open

Test Static Analysis Action from fork#7
JacobDTest wants to merge 13 commits into
JacobDomagala:mainfrom
JacobDTest:test-branch-fork

Conversation

@JacobDTest
Copy link
Copy Markdown
Contributor

No description provided.

Repository owner deleted a comment from github-actions Bot Nov 26, 2021
Repository owner deleted a comment from github-actions Bot Nov 27, 2021
@JacobDomagala JacobDomagala changed the title Update source.cpp Test Static Analysis Action from fork Dec 5, 2021
@JacobDomagala JacobDomagala force-pushed the test-branch-fork branch 4 times, most recently from d298e1b to 1eaca9b Compare December 5, 2021 19:06
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 19, 2025

⚡ SA CMake output ⚡

🔴 cppcheck found 12 issues! Click here to see details.

Issue found in file JacobDTest/TestRepo/another.cpp

#include <stdio.h> <---- HERE

int evaluate(int x) {
    // Create a large number of branches.
!Line: 0 - information: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches. [normalCheckLevelMaxBranches]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    int getElement(int index) { <---- HERE
        // Improper bounds checking: if index is invalid, returns -1.
        // A static analyzer might flag this for potential misuse.
        if (index < 0 || index >= size_) {
            return -1;
!Line: 30 - style: inconclusive: Technically the member function 'DataProcessor::getElement' can be const. [functionConst]


Issue found in file JacobDTest/TestRepo/new_file.cpp

        data_ = new int[size_];  // Dynamic allocation (potential memory leak) <---- HERE
    }

    // Destructor intentionally missing delete[] to trigger memory leak warning.
    ~DataProcessor() {
!Line: 9 - warning: Class 'DataProcessor' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]


Issue found in file JacobDTest/TestRepo/new_file.cpp

        data_ = new int[size_];  // Dynamic allocation (potential memory leak) <---- HERE
    }

    // Destructor intentionally missing delete[] to trigger memory leak warning.
    ~DataProcessor() {
!Line: 9 - warning: Class 'DataProcessor' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    DataProcessor(int size) : size_(size) { <---- HERE
        data_ = new int[size_];  // Dynamic allocation (potential memory leak)
    }

    // Destructor intentionally missing delete[] to trigger memory leak warning.
!Line: 8 - style: Class 'DataProcessor' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    int* data_; <---- HERE
    int size_;
};

int main() {
!Line: 40 - style: Class 'DataProcessor' is unsafe, 'DataProcessor::data_' can leak by wrong usage. [unsafeClassCanLeak]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    if (b == 0) { <---- HERE
        std::cerr << "Warning: Division by zero avoided" << std::endl;
    } else {
        std::cout << "Division result: " << a / b << std::endl;
    }
!Line: 59 - style: The comparison 'b == 0' is always true. [knownConditionTrueFalse]

!Line: 58 - note: 'b' is assigned value '0' here.
!Line: 59 - note: The comparison 'b == 0' is always true.

Issue found in file JacobDTest/TestRepo/new_file.cpp

    int a = 10, b = 0; <---- HERE
    if (b == 0) {
        std::cerr << "Warning: Division by zero avoided" << std::endl;
    } else {
        std::cout << "Division result: " << a / b << std::endl;
!Line: 58 - style: The scope of the variable 'a' can be reduced. [variableScope]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    std::cout << "Uninitialized value: " << uninitialized << std::endl; <---- HERE

    // Intentional potential division by zero.
    int a = 10, b = 0;
    if (b == 0) {
!Line: 55 - error: Uninitialized variable: uninitialized [uninitvar]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    int uninitialized; <---- HERE
    std::cout << "Uninitialized value: " << uninitialized << std::endl;

    // Intentional potential division by zero.
    int a = 10, b = 0;
!Line: 54 - style: Variable 'uninitialized' is not assigned a value. [unassignedVariable]


Issue found in file JacobDTest/TestRepo/source.cpp

    int anotherUnused; <---- HERE
}

int main(int /*argc*/, char** argv){
    int unused = 0;
!Line: 2 - style: Unused variable: anotherUnused [unusedVariable]


Issue found in file JacobDTest/TestRepo/source.cpp

    int unused = 0; <---- HERE
    return 0;
!Line: 6 - style: Variable 'unused' is assigned a value that is never used. [unreadVariable]


@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 19, 2025

⚡ SA non-CMake output ⚡

🔴 cppcheck found 12 issues! Click here to see details.

Issue found in file JacobDTest/TestRepo/another.cpp

#include <stdio.h> <---- HERE

int evaluate(int x) {
    // Create a large number of branches.
!Line: 0 - information: Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches. [normalCheckLevelMaxBranches]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    int getElement(int index) { <---- HERE
        // Improper bounds checking: if index is invalid, returns -1.
        // A static analyzer might flag this for potential misuse.
        if (index < 0 || index >= size_) {
            return -1;
!Line: 30 - style: inconclusive: Technically the member function 'DataProcessor::getElement' can be const. [functionConst]


Issue found in file JacobDTest/TestRepo/new_file.cpp

        data_ = new int[size_];  // Dynamic allocation (potential memory leak) <---- HERE
    }

    // Destructor intentionally missing delete[] to trigger memory leak warning.
    ~DataProcessor() {
!Line: 9 - warning: Class 'DataProcessor' does not have a copy constructor which is recommended since it has dynamic memory/resource management. [noCopyConstructor]


Issue found in file JacobDTest/TestRepo/new_file.cpp

        data_ = new int[size_];  // Dynamic allocation (potential memory leak) <---- HERE
    }

    // Destructor intentionally missing delete[] to trigger memory leak warning.
    ~DataProcessor() {
!Line: 9 - warning: Class 'DataProcessor' does not have a operator= which is recommended since it has dynamic memory/resource management. [noOperatorEq]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    DataProcessor(int size) : size_(size) { <---- HERE
        data_ = new int[size_];  // Dynamic allocation (potential memory leak)
    }

    // Destructor intentionally missing delete[] to trigger memory leak warning.
!Line: 8 - style: Class 'DataProcessor' has a constructor with 1 argument that is not explicit. [noExplicitConstructor]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    int* data_; <---- HERE
    int size_;
};

int main() {
!Line: 40 - style: Class 'DataProcessor' is unsafe, 'DataProcessor::data_' can leak by wrong usage. [unsafeClassCanLeak]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    if (b == 0) { <---- HERE
        std::cerr << "Warning: Division by zero avoided" << std::endl;
    } else {
        std::cout << "Division result: " << a / b << std::endl;
    }
!Line: 59 - style: The comparison 'b == 0' is always true. [knownConditionTrueFalse]

!Line: 58 - note: 'b' is assigned value '0' here.
!Line: 59 - note: The comparison 'b == 0' is always true.

Issue found in file JacobDTest/TestRepo/new_file.cpp

    int a = 10, b = 0; <---- HERE
    if (b == 0) {
        std::cerr << "Warning: Division by zero avoided" << std::endl;
    } else {
        std::cout << "Division result: " << a / b << std::endl;
!Line: 58 - style: The scope of the variable 'a' can be reduced. [variableScope]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    std::cout << "Uninitialized value: " << uninitialized << std::endl; <---- HERE

    // Intentional potential division by zero.
    int a = 10, b = 0;
    if (b == 0) {
!Line: 55 - error: Uninitialized variable: uninitialized [uninitvar]


Issue found in file JacobDTest/TestRepo/new_file.cpp

    int uninitialized; <---- HERE
    std::cout << "Uninitialized value: " << uninitialized << std::endl;

    // Intentional potential division by zero.
    int a = 10, b = 0;
!Line: 54 - style: Variable 'uninitialized' is not assigned a value. [unassignedVariable]


Issue found in file JacobDTest/TestRepo/source.cpp

    int anotherUnused; <---- HERE
}

int main(int /*argc*/, char** argv){
    int unused = 0;
!Line: 2 - style: Unused variable: anotherUnused [unusedVariable]


Issue found in file JacobDTest/TestRepo/source.cpp

    int unused = 0; <---- HERE
    return 0;
!Line: 6 - style: Variable 'unused' is assigned a value that is never used. [unreadVariable]


Signed-off-by: JacobDomagala <domagala.jacob@gmail.com>
Signed-off-by: JacobDomagala <domagala.jacob@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 26, 2025

⚡ Python ⚡

🔴 PyLint found 6 issues! Click here to see details.

Issue found in file JacobDTest/TestRepo/file_with_errors.py

     <---- HERE
    # Run pylint on the provided files
    # You can adjust the options list below as needed
    args = files
    results = lint.Run(args, reporter=reporter, exit=False)
!Line: 19 - C0303: Trailing whitespace (trailing-whitespace)


Issue found in file JacobDTest/TestRepo/file_with_errors.py

     <---- HERE
    # Get the output as a string
    output_str = output.getvalue()
    output.close()
    return results.linter.msg_status, output_str
!Line: 24 - C0303: Trailing whitespace (trailing-whitespace)


Issue found in file JacobDTest/TestRepo/file_with_errors.py

     <---- HERE
    # Exit with the pylint status code to reflect analysis result
    sys.exit(exit_code)

if __name__ == "__main__":
!Line: 41 - C0303: Trailing whitespace (trailing-whitespace)


Issue found in file JacobDTest/TestRepo/file_with_errors.py

def main(): <---- HERE
    if len(sys.argv) < 2:
        print("Usage: {} <python_file.py> [<python_file2.py> ...]".format(sys.argv[0]))
        sys.exit(1)
!Line: 30 - C0116: Missing function or method docstring (missing-function-docstring)


Issue found in file JacobDTest/TestRepo/file_with_errors.py

        print("Usage: {} <python_file.py> [<python_file2.py> ...]".format(sys.argv[0])) <---- HERE
        sys.exit(1)

    files = sys.argv[1:]
    exit_code, report = run_pylint(files)
!Line: 32 - C0209: Formatting a regular string which could be an f-string (consider-using-f-string)


Issue found in file JacobDTest/TestRepo/file_with_errors.py

import io <---- HERE

def run_pylint(files):
    """Run pylint on the list of files and capture the output."""
    # Capture the output in a string buffer
!Line: 12 - C0411: standard import "io" should be placed before third party imports "pylint.lint", "pylint.reporters.text.TextReporter" (wrong-import-order)


Signed-off-by: JacobDomagala <domagala.jacob@gmail.com>
Signed-off-by: JacobDomagala <domagala.jacob@gmail.com>
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