File tree Expand file tree Collapse file tree 8 files changed +27
-19
lines changed
python-checks/src/main/resources/org/sonar/l10n/py/rules/python Expand file tree Collapse file tree 8 files changed +27
-19
lines changed Original file line number Diff line number Diff line change 11< p > Any issue to quality rule can be deactivated with the < code > NOSONAR</ code > marker. This marker is pretty useful to exclude false-positive results
22but it can also be used abusively to hide real quality flaws.</ p >
33< p > This rule raises an issue when < code > NOSONAR</ code > is used.</ p >
4+ < h2 > Noncompliant Code Example</ h2 >
5+ < pre >
6+ for d in lib_dirs:
7+ # NOSONAR: lib_dirs is undefined
8+ pass
9+ </ pre >
410
Original file line number Diff line number Diff line change 1- < p > Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.</ p >
1+ < p > Unused parameters are misleading. Whatever the value passed to such parameters is , the behavior will be the same.</ p >
22< h2 > Noncompliant Code Example</ h2 >
33< pre >
4- def do_something(a, b): # `a` is unused
5- return compute(b )
4+ def do_something(a, b): # "b" is unused
5+ return compute(a )
66</ pre >
77< h2 > Compliant Solution</ h2 >
88< pre >
9- def do_something(b ):
10- return compute(b )
9+ def do_something(a ):
10+ return compute(a )
1111</ pre >
1212< h2 > Exceptions</ h2 >
13- < p > Functions in classes that override a class or implement interfaces are ignored.</ p >
13+ < p > Overriding methods are ignored.</ p >
1414< pre >
15- class Parent(object):
16- def get_value(self, a, b):
17- return compute(a + b);
18-
19- class Child(Patent):
20- def get_value(self, a, b):
21- return compute(b)
15+ class C(B):
16+ def do_something(self, a, b): # no issue reported on b
17+ return self.compute(a)
18+ }
19+ </ pre >
20+ < p > Throwaway variables < code > _</ code > .</ p >
21+ < pre >
22+ def do_something(a, _): # no issue reported on _
23+ return compute(a)
2224</ pre >
2325
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ <h2>Compliant Solution</h2>
3737</ pre >
3838< h2 > See</ h2 >
3939< ul >
40- < li > < a href ="https://owasp.org/Top10/A03_2021-Injection / "> OWASP Top 10 2021 Category A4</ a > - Insecure Design </ li >
40+ < li > < a href ="https://owasp.org/Top10/A04_2021-Insecure_Design / "> OWASP Top 10 2021 Category A4</ a > - Insecure Design </ li >
4141 < li > < a href ="https://owasp.org/Top10/A05_2021-Security_Misconfiguration/ "> OWASP Top 10 2021 Category A5</ a > - Security Misconfiguration </ li >
4242 < li > < a href ="https://www.owasp.org/index.php/Top_10-2017_A3-Sensitive_Data_Exposure "> OWASP Top 10 2017 Category A3</ a > - Sensitive Data Exposure
4343 </ li >
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ <h2>Compliant Solution</h2>
3737< h2 > See</ h2 >
3838< ul >
3939 < li > < a href ="https://owasp.org/Top10/A01_2021-Broken_Access_Control/ "> OWASP Top 10 2021 Category A1</ a > - Broken Access Control </ li >
40- < li > < a href ="https://owasp.org/Top10/A03_2021-Injection / "> OWASP Top 10 2021 Category A4</ a > - Insecure Design </ li >
40+ < li > < a href ="https://owasp.org/Top10/A04_2021-Insecure_Design / "> OWASP Top 10 2021 Category A4</ a > - Insecure Design </ li >
4141 < li > < a href ="https://www.owasp.org/index.php/Top_10-2017_A5-Broken_Access_Control "> OWASP Top 10 2017 Category A5</ a > - Broken Access Control </ li >
4242 < li > < a href ="https://www.owasp.org/index.php/Test_File_Permission_(OTG-CONFIG-009) "> OWASP File Permission</ a > </ li >
4343 < li > < a href ="https://cwe.mitre.org/data/definitions/732.html "> MITRE, CWE-732</ a > - Incorrect Permission Assignment for Critical Resource </ li >
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ <h2>Compliant Solution</h2>
6767< h2 > See</ h2 >
6868< ul >
6969 < li > < a href ="https://owasp.org/Top10/A01_2021-Broken_Access_Control/ "> OWASP Top 10 2021 Category A1</ a > - Broken Access Control </ li >
70- < li > < a href ="https://owasp.org/Top10/A03_2021-Injection / "> OWASP Top 10 2021 Category A4</ a > - Insecure Design </ li >
70+ < li > < a href ="https://owasp.org/Top10/A04_2021-Insecure_Design / "> OWASP Top 10 2021 Category A4</ a > - Insecure Design </ li >
7171 < li > < a href ="https://owasp.org/www-project-top-ten/OWASP_Top_Ten_2017/Top_10-2017_A5-Broken_Access_Control "> OWASP Top 10 2017 Category A5</ a > -
7272 Broken Access Control </ li >
7373 < li > < a href ="https://cwe.mitre.org/data/definitions/352.html "> MITRE, CWE-352</ a > - Cross-Site Request Forgery (CSRF) </ li >
Original file line number Diff line number Diff line change 22difficult to maintain.</ p >
33< h2 > See</ h2 >
44< ul >
5- < li > < a href ="https://redirect .sonarsource.com/doc/cognitive-complexity.html "> Cognitive Complexity</ a > </ li >
5+ < li > < a href ="https://www .sonarsource.com/docs/CognitiveComplexity.pdf "> Cognitive Complexity</ a > </ li >
66</ ul >
77
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ <h2>See</h2>
3535 Sheet</ a > - XSS Prevention Cheat Sheet </ li >
3636 < li > < a href ="https://www.owasp.org/index.php/Top_10-2017_A7-Cross-Site_Scripting_(XSS) "> OWASP Top 10 2017 Category A7</ a > - Cross-Site Scripting
3737 (XSS) </ li >
38- < li > < a href ="https://www.owasp.org/index.php/Top_10-2017_A6-Security_Misconfiguration "> OWASP Top 10 2017 Category A9 </ a > - Security
38+ < li > < a href ="https://www.owasp.org/index.php/Top_10-2017_A6-Security_Misconfiguration "> OWASP Top 10 2017 Category A6 </ a > - Security
3939 Misconfiguration </ li >
4040 < li > < a href ="https://cwe.mitre.org/data/definitions/79.html "> MITRE, CWE-79</ a > - Improper Neutralization of Input During Web Page Generation
4141 ('Cross-site Scripting') </ li >
Original file line number Diff line number Diff line change 33 "languages" : [
44 " PY"
55 ],
6- "latest-update" : " 2022-02-07T13:04 :10.465499Z " ,
6+ "latest-update" : " 2022-03-22T09:43 :10.316991700Z " ,
77 "options" : {
88 "no-language-in-filenames" : true ,
99 "preserve-filenames" : true
You can’t perform that action at this time.
0 commit comments