What is the primary purpose of static analysis tools in software testing?
Think about tools that check code before running it.
Static analysis tools examine the source code without running it to detect errors, code smells, or security issues early.
Given the following Python code snippet, what warning would a static analysis tool most likely report?
def calculate_area(radius): pi = 3.14159 area = pi * radius ** 2 return area result = calculate_area(5) print(result) unused_var = 10
Look for variables declared but never used.
The variable 'unused_var' is declared but never used, which static analysis tools often warn about to help clean code.
Which statement about static analysis tools and assertion failures is correct?
Consider when assertions are checked during program execution.
Assertions check conditions during runtime, so static analysis tools cannot detect failures that depend on actual runtime data.
Which output below is most likely produced by a static analysis tool scanning this JavaScript code?
function add(a, b) {
return a + b;
}
let result = add(5);
console.log(result);Check function calls and argument counts.
The function 'add' expects two arguments, but is called with only one, which static analysis tools detect as a potential bug.
Which approach best integrates static analysis tools into a CI/CD pipeline to improve code quality?
Think about catching issues early in the development process.
Running static analysis on every pull request helps catch issues before code merges, improving quality and reducing bugs.