Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

search-example.json 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. {
  2. "paging": {
  3. "pageSize": 3,
  4. "total": 4,
  5. "pageIndex": 1
  6. },
  7. "rules": [
  8. {
  9. "key": "squid:S1067",
  10. "repo": "squid",
  11. "name": "Expressions should not be too complex",
  12. "createdAt": "2013-03-27T08:52:40+0100",
  13. "updatedAt": "2013-03-27T08:52:40+0100",
  14. "htmlDesc": "<p>\nThe complexity of an expression is defined by the number of <code>&&</code>, <code>||</code> and <code>condition ? ifTrue : ifFalse</code> operators it contains.\nA single expression's complexity should not become too high to keep the code readable.\n</p>\n\n<p>The following code, with a maximum complexity of 3:</p>\n\n<pre>\nif (condition1 && condition2 && condition3 && condition4) { /* ... */ } // Non-Compliant\n</pre>\n\n<p>could be refactored into something like:</p>\n\n<pre>\nif (relevantMethodName1() && relevantMethodName2()) { /* ... */ } // Compliant\n\n/* ... */\n\nprivate boolean relevantMethodName1() {\n return condition1 && condition2;\n}\n\nprivate boolean relevantMethodName2() {\n return condition3 && condition4;\n}\n</pre>",
  15. "severity": "MAJOR",
  16. "status": "READY",
  17. "internalKey": "S1067",
  18. "isTemplate": false,
  19. "tags": [],
  20. "sysTags": [
  21. "brain-overload"
  22. ],
  23. "lang": "java",
  24. "langName": "Java",
  25. "scope": "MAIN",
  26. "isExternal": false,
  27. "type": "CODE_SMELL",
  28. "cleanCodeAttributeCategory": "INTENTIONAL",
  29. "cleanCodeAttribute": "CLEAR",
  30. "impacts": [
  31. {
  32. "softwareQuality": "MAINTAINABILITY",
  33. "severity": "HIGH"
  34. }
  35. ],
  36. "descriptionSections": [
  37. {
  38. "key": "root_cause",
  39. "content": "<h3 class=\"page-title coding-rules-detail-header\"><big>Unnecessary imports should be removed</big></h3>"
  40. },
  41. {
  42. "key": "how_to_fix",
  43. "content": "<h2>Recommended Secure Coding Practices</h2><ul><li> activate Spring Security's CSRF protection. </li></ul>",
  44. "context": {
  45. "displayName": "Spring",
  46. "key": "spring"
  47. }
  48. },
  49. {
  50. "key": "how_to_fix",
  51. "content": "<h2>Recommended Secure Coding Practices</h2><ul><li> activate hibernate protection. </li></ul>",
  52. "context": {
  53. "displayName": "Hibernate",
  54. "key": "hibernate"
  55. }
  56. }
  57. ],
  58. "params": [
  59. {
  60. "key": "max",
  61. "desc": "Maximum number of allowed conditional operators in an expression",
  62. "defaultValue": "3"
  63. }
  64. ]
  65. },
  66. {
  67. "key": "squid:ClassCyclomaticComplexity",
  68. "repo": "squid",
  69. "name": "Avoid too complex class",
  70. "createdAt": "2013-03-27T08:52:40+0100",
  71. "updatedAt": "2013-03-27T08:52:40+0100",
  72. "htmlDesc": "<p>The Cyclomatic Complexity is measured by the number of (&&, ||)\n\toperators and (if, while, do, for, ?:, catch, switch, case, return,\n\tthrow) statements in the body of a class plus one for each constructor,\n\tmethod (but not getter/setter), static initializer, or instance\n\tinitializer in the class. The last return stament in method, if exists,\n\tis not taken into account.</p>\n<p>\n\tEven when the Cyclomatic Complexity of a class is very high, this\n\tcomplexity might be well distributed among all methods. Nevertheless,\n\tmost of the time, a very complex class is a class which breaks the <a\n\t\thref='http://en.wikipedia.org/wiki/Single_responsibility_principle'>Single\n\t\tResponsibility Principle</a> and which should be re-factored to be split\n\tin several classes.\n</p>",
  73. "severity": "MAJOR",
  74. "status": "READY",
  75. "internalKey": "ClassCyclomaticComplexity",
  76. "isTemplate": false,
  77. "tags": [],
  78. "sysTags": [
  79. "brain-overload"
  80. ],
  81. "lang": "java",
  82. "langName": "Java",
  83. "scope": "MAIN",
  84. "isExternal": false,
  85. "type": "BUG",
  86. "cleanCodeAttributeCategory": "INTENTIONAL",
  87. "cleanCodeAttribute": "CLEAR",
  88. "impacts": [
  89. {
  90. "softwareQuality": "RELIABILITY",
  91. "severity": "HIGH"
  92. }
  93. ],
  94. "params": [
  95. {
  96. "key": "max",
  97. "desc": "Maximum complexity allowed.",
  98. "defaultValue": "200"
  99. }
  100. ]
  101. },
  102. {
  103. "key": "squid:MethodCyclomaticComplexity",
  104. "repo": "squid",
  105. "name": "Methods should not be too complex",
  106. "createdAt": "2013-03-27T08:52:40+0100",
  107. "updatedAt": "2013-03-27T08:52:40+0100",
  108. "htmlDesc": "<p>The Cyclomatic Complexity is measured by the number of\n\t(&amp;&amp;, ||) operators and (if, while, do, for, ?:, catch, switch,\n\tcase, return, throw) statements in the body of a class plus one for\n\teach constructor, method (but not getter/setter), static initializer,\n\tor instance initializer in the class. The last return stament in\n\tmethod, if exists, is not taken into account.</p>\n<p>\n\tEven when the Cyclomatic Complexity of a class is very high, this\n\tcomplexity might be well distributed among all methods. Nevertheless,\n\tmost of the time, a very complex class is a class which breaks the <a\n\t\thref=\"http://en.wikipedia.org/wiki/Single_responsibility_principle\">Single\n\t\tResponsibility Principle</a> and which should be re-factored to be split\n\tin several classes.\n</p>",
  109. "severity": "MAJOR",
  110. "status": "READY",
  111. "internalKey": "MethodCyclomaticComplexity",
  112. "isTemplate": false,
  113. "tags": [],
  114. "sysTags": [
  115. "brain-overload"
  116. ],
  117. "lang": "java",
  118. "langName": "Java",
  119. "scope": "MAIN",
  120. "isExternal": false,
  121. "type": "VULNERABILITY",
  122. "cleanCodeAttributeCategory": "INTENTIONAL",
  123. "cleanCodeAttribute": "CLEAR",
  124. "impacts": [
  125. {
  126. "softwareQuality": "SECURITY",
  127. "severity": "HIGH"
  128. }
  129. ],
  130. "params": [
  131. {
  132. "key": "max",
  133. "desc": "Maximum complexity allowed.",
  134. "defaultValue": "10"
  135. }
  136. ]
  137. },
  138. {
  139. "key": "squid:XPath",
  140. "repo": "squid",
  141. "name": "XPath rule",
  142. "createdAt": "2013-03-27T08:52:40+0100",
  143. "updatedAt": "2013-03-27T08:52:40+0100",
  144. "htmlDesc": "<p>\nThis rule allows to define some homemade Java rules with help of an XPath expression.\n</p>\n\n<p>\nIssues are created depending on the return value of the XPath expression. If the XPath expression returns:\n</p>\n<ul>\n <li>a single or list of AST nodes, then a line issue with the given message is created for each node</li>\n <li>a boolean, then a file issue with the given message is created only if the boolean is true</li>\n <li>anything else, no issue is created</li>\n</ul>\n\n<p>\nHere is an example of an XPath expression to log an issue on each if statement : //ifStatement\n</p>",
  145. "severity": "MAJOR",
  146. "status": "READY",
  147. "internalKey": "XPath",
  148. "isTemplate": true,
  149. "tags": [],
  150. "sysTags": [],
  151. "mdNote": "<p>\nThe tree produced by the <code>firstOf()</code> matcher is hard to work with from checks when alternatives are not named.\n</p>\n\n<p>\nConsider the following rule:\n</p>\n\n<pre>\nb.rule(COMPILATION_UNIT).is(\n b.firstOf( /* Non-Compliant */\n \"FOO\",\n \"BAR\"));\n</pre>\n\n<p>\nIf, from a check, one wants to forbid the usage of the \"BAR\" alternative,\nthe easiest option will be to verify that the value of the first token is \"BAR\",\ni.e. <code>\"BAR\".equals(compilationUnitNode.getTokenValue())</code>.\n</p>\n\n<p>\nThis is not maintainable, for at least two reasons:\n</p>\n\n<ul>\n <li>The grammar might evolve to also accept \"bar\" in lowercase, which will break <code>\"BAR\".equals(...)</code></li>\n <li>The grammar might evolve to optionally accept \"hello\" before the <code>firstOf()</code>, which will break <code>compilationUnitNode.getTokenValue()</code></li>\n</ul>\n\n<p>\nInstead, it is much better to rewrite the grammar as:\n</p>\n\n<pre>\nb.rule(COMPILATION_UNIT).is(\n firstOf( /* Compliant */\n FOO,\n BAR));\nb.rule(FOO).is(\"FOO\");\nb.rule(BAR).is(\"BAR\");\n</pre>\n\n<p>\nThe same check which forbids \"BAR\" would be written as: <code>compilationUnitNode.hasDirectChildren(BAR)</code>.\nThis allows both of the previous grammar evolutions to be made without impacting the check at all.\n</p>",
  152. "htmlNote": "&lt;p&gt;<br/>The tree produced by the &lt;code&gt;firstOf()&lt;/code&gt; matcher is hard to work with from checks when alternatives are not named.<br/>&lt;/p&gt;<br/><br/>&lt;p&gt;<br/>Consider the following rule:<br/>&lt;/p&gt;<br/><br/>&lt;pre&gt;<br/>b.rule(COMPILATION_UNIT).is(<br/> b.firstOf( /* Non-Compliant */<br/> &quot;FOO&quot;,<br/> &quot;BAR&quot;));<br/>&lt;/pre&gt;<br/><br/>&lt;p&gt;<br/>If, from a check, one wants to forbid the usage of the &quot;BAR&quot; alternative,<br/>the easiest option will be to verify that the value of the first token is &quot;BAR&quot;,<br/>i.e. &lt;code&gt;&quot;BAR&quot;.equals(compilationUnitNode.getTokenValue())&lt;/code&gt;.<br/>&lt;/p&gt;<br/><br/>&lt;p&gt;<br/>This is not maintainable, for at least two reasons:<br/>&lt;/p&gt;<br/><br/>&lt;ul&gt;<br/> &lt;li&gt;The grammar might evolve to also accept &quot;bar&quot; in lowercase, which will break &lt;code&gt;&quot;BAR&quot;.equals(...)&lt;/code&gt;&lt;/li&gt;<br/> &lt;li&gt;The grammar might evolve to optionally accept &quot;hello&quot; before the &lt;code&gt;firstOf()&lt;/code&gt;, which will break &lt;code&gt;compilationUnitNode.getTokenValue()&lt;/code&gt;&lt;/li&gt;<br/>&lt;/ul&gt;<br/><br/>&lt;p&gt;<br/>Instead, it is much better to rewrite the grammar as:<br/>&lt;/p&gt;<br/><br/>&lt;pre&gt;<br/>b.rule(COMPILATION_UNIT).is(<br/> firstOf( /* Compliant */<br/> FOO,<br/> BAR));<br/>b.rule(FOO).is(&quot;FOO&quot;);<br/>b.rule(BAR).is(&quot;BAR&quot;);<br/>&lt;/pre&gt;<br/><br/>&lt;p&gt;<br/>The same check which forbids &quot;BAR&quot; would be written as: &lt;code&gt;compilationUnitNode.hasDirectChildren(BAR)&lt;/code&gt;.<br/>This allows both of the previous grammar evolutions to be made without impacting the check at all.<br/>&lt;/p&gt;",
  153. "noteLogin": "eric.hartmann",
  154. "lang": "java",
  155. "langName": "Java",
  156. "scope": "MAIN",
  157. "isExternal": false,
  158. "type": "CODE_SMELL",
  159. "params": [
  160. {
  161. "key": "xpathQuery",
  162. "desc": "The XPath query",
  163. "defaultValue": ""
  164. },
  165. {
  166. "key": "message",
  167. "desc": "The violation message",
  168. "defaultValue": "The XPath expression matches this piece of code"
  169. }
  170. ]
  171. },
  172. {
  173. "key": "squid:XPath_1369910135",
  174. "repo": "squid",
  175. "name": "firstOf() alternatives should be rules or token types",
  176. "createdAt": "2013-05-30T10:35:35+0200",
  177. "updatedAt": "2013-03-27T08:52:40+0100",
  178. "htmlDesc": "<p>\r\nThe tree produced by the <code>firstOf()</code> matcher is hard to work with from checks when alternatives are not named.\r\n</p>\r\n\r\n<p>\r\nConsider the following rule:\r\n</p>\r\n\r\n<pre>\r\nb.rule(COMPILATION_UNIT).is(\r\n b.firstOf( /* Non-Compliant */\r\n \"FOO\",\r\n \"BAR\"));\r\n</pre>\r\n\r\n<p>\r\nIf, from a check, one wants to forbid the usage of the \"BAR\" alternative,\r\nthe easiest option will be to verify that the value of the first token is \"BAR\",\r\ni.e. <code>\"BAR\".equals(compilationUnitNode.getTokenValue())</code>.\r\n</p>\r\n\r\n<p>\r\nThis is not maintainable, for at least two reasons:\r\n</p>\r\n\r\n<ul>\r\n <li>The grammar might evolve to also accept \"bar\" in lowercase, which will break <code>\"BAR\".equals(...)</code></li>\r\n <li>The grammar might evolve to optionally accept \"hello\" before the <code>firstOf()</code>, which will break <code>compilationUnitNode.getTokenValue()</code></li>\r\n</ul>\r\n\r\n<p>\r\nInstead, it is much better to rewrite the grammar as:\r\n</p>\r\n\r\n<pre>\r\nb.rule(COMPILATION_UNIT).is(\r\n firstOf( /* Compliant */\r\n FOO,\r\n BAR));\r\nb.rule(FOO).is(\"FOO\");\r\nb.rule(BAR).is(\"BAR\");\r\n</pre>\r\n\r\n<p>\r\nThe same check which forbids \"BAR\" would be written as: <code>compilationUnitNode.hasDirectChildren(BAR)</code>.\r\nThis allows both of the previous grammar evolutions to be made without impacting the check at all.\r\n</p>",
  179. "severity": "MAJOR",
  180. "status": "READY",
  181. "internalKey": "XPath",
  182. "isTemplate": false,
  183. "templateKey": "squid:XPath",
  184. "tags": [],
  185. "sysTags": [],
  186. "lang": "java",
  187. "langName": "Java",
  188. "scope": "MAIN",
  189. "isExternal": false,
  190. "type": "CODE_SMELL",
  191. "cleanCodeAttributeCategory": "INTENTIONAL",
  192. "cleanCodeAttribute": "CLEAR",
  193. "impacts": [
  194. {
  195. "softwareQuality": "MAINTAINABILITY",
  196. "severity": "HIGH"
  197. }
  198. ],
  199. "params": [
  200. {
  201. "key": "xpathQuery",
  202. "desc": "The XPath query",
  203. "defaultValue": "//expression[primary/qualifiedIdentifier[count(IDENTIFIER) = 2]/IDENTIFIER[2]/@tokenValue = 'firstOf' and primary/identifierSuffix/arguments/expression[not(primary) or primary[not(qualifiedIdentifier) or identifierSuffix]]]"
  204. },
  205. {
  206. "key": "message",
  207. "desc": "The violation message",
  208. "defaultValue": "Refactor this firstOf() to only use a rule or token type for each alternative."
  209. }
  210. ]
  211. }
  212. ],
  213. "actives": {
  214. "squid:MethodCyclomaticComplexity": [
  215. {
  216. "qProfile": "Sonar way with Findbugs:java",
  217. "inherit": "NONE",
  218. "severity": "MAJOR",
  219. "params": [
  220. {
  221. "key": "max",
  222. "value": "10"
  223. }
  224. ]
  225. },
  226. {
  227. "qProfile": "Sonar way:java",
  228. "inherit": "NONE",
  229. "severity": "MAJOR",
  230. "params": [
  231. {
  232. "key": "max",
  233. "value": "10"
  234. }
  235. ]
  236. }
  237. ],
  238. "squid:S1067": [
  239. {
  240. "qProfile": "Sonar way with Findbugs:java",
  241. "inherit": "NONE",
  242. "severity": "MAJOR",
  243. "params": [
  244. {
  245. "key": "max",
  246. "value": "3"
  247. }
  248. ]
  249. },
  250. {
  251. "qProfile": "Sonar way:java",
  252. "inherit": "NONE",
  253. "severity": "MAJOR",
  254. "params": [
  255. {
  256. "key": "max",
  257. "value": "3"
  258. }
  259. ]
  260. }
  261. ],
  262. "squid:ClassCyclomaticComplexity": [
  263. {
  264. "qProfile": "Sonar way with Findbugs:java",
  265. "inherit": "NONE",
  266. "severity": "MAJOR",
  267. "params": [
  268. {
  269. "key": "max",
  270. "value": "200"
  271. }
  272. ]
  273. },
  274. {
  275. "qProfile": "Sonar way:java",
  276. "inherit": "NONE",
  277. "severity": "MAJOR",
  278. "params": [
  279. {
  280. "key": "max",
  281. "value": "200"
  282. }
  283. ]
  284. }
  285. ]
  286. },
  287. "facets": [
  288. {
  289. "name": "tags",
  290. "values": [
  291. {
  292. "val": "complexity",
  293. "count": 141
  294. },
  295. {
  296. "val": "java8",
  297. "count": 42
  298. },
  299. {
  300. "val": "javadoc",
  301. "count": 13
  302. }
  303. ]
  304. },
  305. {
  306. "name": "languages",
  307. "values": [
  308. {
  309. "val": "java",
  310. "count": 563
  311. }
  312. ]
  313. },
  314. {
  315. "name": "repositories",
  316. "values": [
  317. {
  318. "val": "findbugs",
  319. "count": 419
  320. },
  321. {
  322. "val": "squid",
  323. "count": 138
  324. },
  325. {
  326. "val": "common-java",
  327. "count": 6
  328. }
  329. ]
  330. }
  331. ]
  332. }