Test Static Analysis Action from fork#7
Conversation
7d85d02 to
2ae9d8c
Compare
d298e1b to
1eaca9b
Compare
1eaca9b to
db34471
Compare
772cd89 to
9c3f734
Compare
|
⚡ 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]
|
|
⚡ 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>
|
⚡ 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>
No description provided.