{"id":379414,"date":"2024-06-21T21:00:20","date_gmt":"2024-06-21T21:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=379414"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=379414","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 Plugin SonarQube<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 SonarQube \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u043e\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0432\u044b \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043b\u0430\u0433\u0438\u043d \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438. <\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cfc\/e10\/92a\/cfce1092aae853257b28c9096ca245e7.png\" width=\"1024\" height=\"1024\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cfc\/e10\/92a\/cfce1092aae853257b28c9096ca245e7.png\"\/><\/figure>\n<h2>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0432\u0432\u043e\u0434\u043d\u044b\u0435 <\/h2>\n<p>Disclaimer: \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u043c\u043d\u043e\u0433\u043e\u0435 \u0438\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e <a href=\"https:\/\/github.com\/SonarSource\/sonar-java\/blob\/master\/docs\/CUSTOM_RULES_101.md\" rel=\"noopener noreferrer nofollow\"><strong>\u0433\u0430\u0439\u0434\u0430<\/strong><\/a>.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0432\u044b\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e use-case&#8217;a:<\/p>\n<p><strong><em>\u041d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f MR, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434-\u0441\u0442\u0430\u0439\u043b\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/em><\/strong> <\/p>\n<p>\u0422\u0443\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 Lint-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/h4>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u0430\u043a\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c ESLint (\u0434\u043b\u044f JavaScript\/TypeScript) \u0438\u043b\u0438 Checkstyle (\u0434\u043b\u044f Java). \u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u0412 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0441\u043b\u043e\u0436\u0435\u043d: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0439 \u0447\u0435\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e plugins \u0438\u043b\u0438 extensions.<\/p>\n<p><strong>\u041f\u043b\u044e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041c\u0438\u043d\u0443\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SonarQube \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u043c<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043c\u0435\u043d\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u0434-\u0441\u0442\u0430\u0439\u043b\u0438\u043d\u0433\u043e\u043c \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0434\u0430, \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435. SonarQube \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0438.<\/p>\n<p><strong>\u041f\u043b\u044e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u043e\u0431\u043d\u044b\u0439 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041c\u0438\u043d\u0443\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435:<\/strong> SonarQube \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0447\u0435\u043a\u0430 \u0441\u043f\u0443\u043b\u0438\u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0433\u0438\u0442\u0445\u0430\u0431\u0430: <a href=\"https:\/\/github.com\/LordBarov\/java-sonar-tutorial\" rel=\"noopener noreferrer nofollow\"><strong>\u0441\u0441\u044b\u043b\u043a\u0430<\/strong><\/a>.<\/p>\n<p>\u042f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u043b \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0441 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 Maven.<\/p>\n<p>\u041f\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 SonarQube, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430 <a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/450316\/\" rel=\"noopener noreferrer nofollow\"><strong>TDD<\/strong><\/a><strong> <\/strong>(\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435) \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0447\u0435\u043a\u043e\u0432. \u041b\u0438\u0447\u043d\u043e \u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0447\u0435\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u043e\u0441\u043b\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 SonarQube, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 <strong>CheckVerifier.<\/strong> \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0435\u0439\u0441\u0430\u0445, \u0447\u0442\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435, \u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u043a\u043e\u0432 \u0432 Mockito.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u0447\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043b\u0438 URL \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u043e\u0432 \u0432 <a href=\"https:\/\/medium.com\/@vladimirmorulus\/%D1%81%D0%BF%D1%80%D0%B0%D0%B2%D0%BA%D0%B0-%D0%BF%D0%BE-case-camelcase-kebab-case-pascalcase-snake-case-%D0%B8-%D0%B2%D1%81%D0%B5-case-ecda10463fa8\" rel=\"noopener noreferrer nofollow\">kebab-case<\/a>.<\/p>\n<pre><code class=\"java\">import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping;  public class MyController {      @GetMapping(\"\/kebab-case-url\") \/\/ Compliant     public String getCompliant() {         return \"compliant\";     }      @GetMapping(\"\/camelCaseUrl\") \/\/ Noncompliant     public String getNonCompliant() {         return \"noncompliant\";     }      @PostMapping(\"\/another-kebab-case-url\") \/\/ Compliant     public void postCompliant() {     }      @PostMapping(\"\/AnotherCamelCaseUrl\") \/\/ Noncompliant     public void postNonCompliant() {     }      @PutMapping(\"\/yet-another-kebab-case-url\") \/\/ Compliant     public void putCompliant() {     }      @PutMapping(\"\/YetAnotherCamelCaseUrl\") \/\/ Noncompliant     public void putNonCompliant() {     }      @DeleteMapping(\"\/final-kebab-case-url\") \/\/ Compliant     public void deleteCompliant() {     }      @DeleteMapping(\"\/FinalCamelCaseUrl\") \/\/ Noncompliant     public void deleteNonCompliant() {     } }<\/code><\/pre>\n<h4>\u0412\u0430\u0436\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0442\u0435\u0441\u0442-\u043a\u0435\u0439\u0441\u043e\u0432<\/h4>\n<ol>\n<li>\n<p><strong>\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0435 \u0432\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438: <code>src\/test\/files\/<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435 \u043a\u0430\u043a \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0435, \u0442\u0430\u043a \u0438 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e\u043c\u0435\u0447\u0430\u0439\u0442\u0435 \u043a\u0430\u043a <code>\/\/ Noncompliant<\/code>, \u0430 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u043a\u0430\u043a <code>\/\/ Compliant<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0418\u043c\u043f\u043e\u0440\u0442\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b. \u0411\u0435\u0437 \u043d\u0438\u0445 \u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0443\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 kebab-case. <\/p>\n<pre><code class=\"java\">@Rule(key = \"KebabCaseUrlCheck\") public class KebabCaseUrlCheck extends BaseTreeVisitor implements JavaFileScanner {      private static final Pattern KEBAB_CASE_PATTERN = Pattern.compile(\"^(\/[a-z0-9]+(-[a-z0-9]+)*)*$\");      private JavaFileScannerContext context;      @Override     public void scanFile(JavaFileScannerContext context) {         this.context = context;         scan(context.getTree());     }      @Override     public void visitMethod(MethodTree tree) {         List&lt;AnnotationTree> annotations = tree.modifiers().annotations();         for (AnnotationTree annotationTree : annotations) {             TypeTree annotationType = annotationTree.annotationType();             if (annotationType.is(Tree.Kind.IDENTIFIER)) {                 IdentifierTree identifier = (IdentifierTree) annotationType;                 String annotationName = identifier.name();                 if (annotationName.equals(\"GetMapping\") || annotationName.equals(\"PostMapping\") ||                         annotationName.equals(\"PutMapping\") || annotationName.equals(\"DeleteMapping\")) {                     checkUrl(annotationTree);                 }             }         }         super.visitMethod(tree);     }      private void checkUrl(AnnotationTree annotationTree) {         if (annotationTree.arguments().isEmpty()) {             return;         }          Tree argument = annotationTree.arguments().get(0);         if (argument.is(Tree.Kind.ASSIGNMENT)) {             argument = ((org.sonar.plugins.java.api.tree.AssignmentExpressionTree) argument).expression();         }          if (argument.is(Tree.Kind.STRING_LITERAL)) {             LiteralTree literal = (LiteralTree) argument;             String url = literal.value().substring(1, literal.value().length() - 1);              if (!KEBAB_CASE_PATTERN.matcher(url).matches()) {                 context.reportIssue(this, literal, \"The URL should be in kebab-case.\");             }         }     } }<\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <a class=\"mention\" href=\"\/users\/Rule\">@Rule<\/a>(key = &#171;KebabCaseUrlCheck&#187;), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043b\u044e\u0447 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432 SonarQube \u0434\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0447\u0435\u043a\u0430. \u041a\u043b\u0430\u0441\u0441 <strong><em>KebabCaseUrlCheck<\/em><\/strong> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <em>BaseTreeVisitor<\/em> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 JavaFileScanner, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0435\u043c\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c Java-\u0444\u0430\u0439\u043b\u044b.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f URL \u0444\u043e\u0440\u043c\u0430\u0442\u0443 kebab-case \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">private static final Pattern KEBAB_CASE_PATTERN = Pattern.compile(\"^(\/[a-z0-9]+(-[a-z0-9]+))$\");.<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u0447\u0435\u0442\u0430 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445: <\/p>\n<pre><code class=\"java\">private JavaFileScannerContext context;<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 scanFile \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430: <\/p>\n<pre><code class=\"java\">@Override public void scanFile(JavaFileScannerContext context);<\/code><\/pre>\n<p> \u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u043c <\/p>\n<pre><code class=\"java\">scan(context.getTree());<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <strong><em>visitMethod<\/em><\/strong> \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435: <\/p>\n<pre><code class=\"java\"> public void visitMethod(MethodTree tree);<\/code><\/pre>\n<p>\u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430: <\/p>\n<pre><code class=\"java\">List&lt;AnnotationTree> annotations = tree.modifiers().annotations();<\/code><\/pre>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0435 for \u043a\u0430\u0436\u0434\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 <code><a class=\"mention\" href=\"\/users\/GetMapping\">@GetMapping<\/a><\/code>, <code><a class=\"mention\" href=\"\/users\/PostMapping\">@PostMapping<\/a><\/code>, <code><a class=\"mention\" href=\"\/users\/PutMapping\">@PutMapping<\/a><\/code> \u0438\u043b\u0438 <code><a class=\"mention\" href=\"\/users\/DeleteMapping\">@DeleteMapping<\/a><\/code>, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <strong>checkUrl<\/strong>.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>checkUrl<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 URL \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0443 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435\u0442, \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f. \u0417\u0430\u0442\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u043d \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u043c. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a: <\/p>\n<pre><code class=\"java\">String url = literal.value().substring(1, literal.value().length() - 1);<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 URL \u0448\u0430\u0431\u043b\u043e\u043d\u0443 kebab-case: <code>if (!KEBAB_CASE_PATTERN.matcher(url).matches())<\/code>. \u0415\u0441\u043b\u0438 URL \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u0443, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0447\u0435\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c &#171;The URL should be in kebab-case.&#187;<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0442\u0435\u0441\u0442-\u043a\u0435\u0439\u0441\u044b \u0438 \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<br \/>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>src\/test\/java\/org\/sonar\/samples\/java\/checks<\/code>  \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>KebabCaseUrlTest<\/code>  \u0438 \u043f\u0438\u0448\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"java\">package org.sonar.samples.java.checks;  import org.junit.jupiter.api.Test; import org.sonar.java.checks.verifier.CheckVerifier;  public class KebabCaseUrlCheckTest {      @Test     void test() {         CheckVerifier.newVerifier()                 .onFile(\"src\/test\/files\/KebabCaseUrlCheck.java\")                 .withCheck(new KebabCaseUrlCheck())                 .verifyIssues();     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0435\u0441\u0442 \u0438 \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 url \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0442\u0440\u0438\u0445\u0438<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u0439\u043c\u0438\u043d\u0433\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u0430. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u044d\u0442\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443:<\/p>\n<p><code>src\/main\/java\/org\/sonar\/samples\/java\/MyJavaRulesDefinition.java<\/code> \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u043f\u043e\u043b\u044f REPOSITORY_KEY \u0438 REPOSITORY_NAME \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u0430\u043c.<\/p>\n<pre><code class=\"java\">public static final String REPOSITORY_KEY = \"sonar-plugin-habr\"; public static final String REPOSITORY_NAME = \"Habr Guide Plugin\";<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0442\u044c \u043d\u0430\u0448 .jar \u0444\u0430\u0439\u043b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043f\u043b\u0430\u0433\u0438\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u044d\u0442\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443: <code>src\/main\/java\/org\/sonar\/samples\/java\/RulesList.java<\/code> <\/p>\n<p>\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>getJavaChecks<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 KebabCaseUrlCheck.<\/p>\n<pre><code class=\"java\">public static List&lt;Class&lt;? extends JavaCheck>> getJavaChecks() {     return Collections.unmodifiableList(Arrays.asList(             SpringControllerRequestMappingEntityRule.class,             AvoidAnnotationRule.class,             AvoidBrandInMethodNamesRule.class,             AvoidMethodDeclarationRule.class,             AvoidSuperClassRule.class,             AvoidTreeListRule.class,             MyCustomSubscriptionRule.class,             KebabCaseUrlCheck.class,             SecurityAnnotationMandatoryRule.class));   }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448 \u0444\u0430\u0439\u043b \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0432 \u0442\u0435\u0441\u0442, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u0430\u0432\u0438\u043b. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>containsExactly()<\/code> \u0447\u0442\u043e \u043a\u0430\u043a \u043f\u043e \u043c\u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u043e\u0439 \u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e\u0439, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e, \u043f\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u044e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043d\u0430 <code>containsExactlyInAnyOrder()<\/code> \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043a\u0438\u0434\u0430\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443, \u0435\u0441\u043b\u0438 \u0432\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0435 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443. <\/p>\n<pre><code class=\"java\">class MyJavaFileCheckRegistrarTest {    @Test   void checkRegisteredRulesKeysAndClasses() {     TestCheckRegistrarContext context = new TestCheckRegistrarContext();      MyJavaFileCheckRegistrar registrar = new MyJavaFileCheckRegistrar();     registrar.register(context);      assertThat(context.mainRuleKeys).extracting(RuleKey::toString).containsExactlyInAnyOrder(             \"omni-sonar:SpringControllerRequestMappingEntity\",             \"omni-sonar:AvoidAnnotation\",             \"omni-sonar:AvoidBrandInMethodNames\",             \"omni-sonar:AvoidMethodDeclaration\",             \"omni-sonar:AvoidSuperClass\",             \"omni-sonar:AvoidTreeList\",             \"omni-sonar:AvoidMethodWithSameTypeInArgument\",             \"omni-sonar:KebabCaseUrlCheck\",             \"omni-sonar:SecurityAnnotationMandatory\");      assertThat(context.mainCheckClasses).extracting(Class::getSimpleName).containsExactlyInAnyOrder(             \"SpringControllerRequestMappingEntityRule\",             \"AvoidAnnotationRule\",             \"AvoidBrandInMethodNamesRule\",             \"AvoidMethodDeclarationRule\",             \"AvoidSuperClassRule\",             \"AvoidTreeListRule\",             \"MyCustomSubscriptionRule\",             \"KebabCaseUrlCheck\",             \"SecurityAnnotationMandatoryRule\");      assertThat(context.testRuleKeys).extracting(RuleKey::toString).containsExactly(             \"omni-sonar:NoIfStatementInTests\");      assertThat(context.testCheckClasses).extracting(Class::getSimpleName).containsExactly(             \"NoIfStatementInTestsRule\");   }  }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043f\u0443\u043d\u043a\u0442, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u043c\u0443 \u043f\u043b\u0430\u0433\u0438\u043d\u0443. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e, \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c 2 \u0444\u0430\u0439\u043b\u0430(html \u0438 json) \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>src\/main\/resources\/org\/sonar\/l10n\/java\/rules\/java<\/code> \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0447\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0444\u0430\u0439\u043b\u044b \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f: KebabCaseUrlCheck.html \u0438 KebabCaseUrlCheck.json.<\/p>\n<p>\u0412 HTML \u0444\u0430\u0439\u043b\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0438 \u043a\u0430\u043a \u043e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u043e\u0434 \u043f\u043e\u043c\u0435\u0449\u0430\u0439\u0442\u0435 \u0432 \u0442\u044d\u0433 &lt;pre>.<\/p>\n<pre><code class=\"xml\">&lt;h1>Kebab-Case URL Check&lt;\/h1> &lt;p>This rule ensures that the URLs in &lt;code>@GetMapping&lt;\/code>, &lt;code>@PostMapping&lt;\/code>, &lt;code>@PutMapping&lt;\/code>, and &lt;code>@DeleteMapping&lt;\/code> annotations are in kebab-case format.&lt;\/p>  &lt;h2>Noncompliant Code Example&lt;\/h2> &lt;pre> import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping;  public class MyController {      @GetMapping(\"\/camelCaseUrl\") \/\/ Noncompliant     public String getNonCompliant() {         return \"noncompliant\";     }      @PostMapping(\"\/AnotherCamelCaseUrl\") \/\/ Noncompliant     public void postNonCompliant() {     }      @PutMapping(\"\/YetAnotherCamelCaseUrl\") \/\/ Noncompliant     public void putNonCompliant() {     }      @DeleteMapping(\"\/FinalCamelCaseUrl\") \/\/ Noncompliant     public void deleteNonCompliant() {     }      @GetMapping(\"\/nested\/camelCaseUrl\") \/\/ Noncompliant     public String getNestedNonCompliant() {         return \"noncompliant\";     } }     &lt;\/pre>  &lt;h2>Compliant Solution&lt;\/h2> &lt;pre> import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping;  public class MyController {      @GetMapping(\"\/kebab-case-url\") \/\/ Compliant     public String getCompliant() {         return \"compliant\";     }      @PostMapping(\"\/another-kebab-case-url\") \/\/ Compliant     public void postCompliant() {     }      @PutMapping(\"\/yet-another-kebab-case-url\") \/\/ Compliant     public void putCompliant() {     }      @DeleteMapping(\"\/final-kebab-case-url\") \/\/ Compliant     public void deleteCompliant() {     }      @GetMapping(\"\/nested\/kebab-case-url\") \/\/ Compliant     public String getNestedCompliant() {         return \"compliant\";     } } &lt;\/pre><\/code><\/pre>\n<p>\u0412 Json \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u0448\u0435\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<pre><code class=\"json\">{   \"title\": \"URLs in @GetMapping, @PostMapping, @PutMapping, @DeleteMapping should be in kebab-case\",   \"type\": \"code_smell\",   \"status\": \"ready\",   \"tags\": [     \"convention\",     \"style\",     \"rest\"   ],   \"defaultSeverity\": \"Minor\" } <\/code><\/pre>\n<p>\u0422\u0443\u0442 \u0438\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u0432\u0441\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0441 type \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u043f\u043e <a href=\"https:\/\/docs.sonarsource.com\/sonarqube\/9.8\/user-guide\/issues\/#:~:text=Issue%20types,confusing%20and%20difficult%20to%20maintain.\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>\u041a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0448\u0442\u0440\u0438\u0445, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c <strong><em>mvn clean install <\/em><\/strong>\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043c .jar \u0444\u0430\u0439\u043b \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <strong><em>\/target<\/em><\/strong><\/p>\n<h2>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0432 SonarQube<\/h2>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043c\u044b sonar \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0448 .jar \u0444\u0430\u0439\u043b.<br \/>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0434\u0430\u043d\u043d\u044b\u0439 Dockerfile:<\/p>\n<pre><code class=\"yaml\"># Use the official SonarQube image as the base image FROM sonarqube:latest  # Set the SonarQube home directory as an environment variable ENV SONAR_HOME=\/opt\/sonarqube  # Copy the custom rules JAR file to the SonarQube plugins directory COPY target\/java-custom-rules-example-1.0.0-SNAPSHOT.jar $SONAR_HOME\/extensions\/plugins\/ <\/code><\/pre>\n<p>\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code>docker build . -t sonar-habr docker run -d -p 9000:9000 sonar-habr<\/code><\/pre>\n<h2>\u0410\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0435\u043c \u041f\u043b\u0430\u0433\u0438\u043d<\/h2>\n<ol>\n<li>\n<p>\u0417\u0430\u0445\u043e\u0434\u0438\u0442\u0435 \u0432 Quality Profiles \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u0444\u0438\u043b\u044c\u0442\u0440 \u043d\u0430 \u044f\u0437\u044b\u043a Java.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u0439\u0434\u0438\u0442\u0435 \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u044c <a href=\"http:\/\/localhost:9000\/profiles\/show?name=Sonar+way&amp;language=java\" rel=\"noopener noreferrer nofollow\">SonarWay<\/a> \u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0435\u0433\u043e \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 habr.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043f\u0440\u043e\u0444\u0438\u043b\u0435 <a href=\"http:\/\/localhost:9000\/profiles\/show?name=habr&amp;language=java\" rel=\"noopener noreferrer nofollow\">habr<\/a> \u043d\u0430\u0436\u043c\u0438\u0442\u0435 activate more \u0438 \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 Repository \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u043d\u0430\u0448 \u043f\u043b\u0430\u0433\u0438\u043d &#171;Habr Guide Plugin&#187;.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u043d\u0430\u0448\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0438 \u0430\u043a\u0442\u0438\u0432\u0438\u0440\u0443\u0439\u0442\u0435 \u0435\u0435, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f <strong><em>URLs in @GetMapping, @PostMapping, @PutMapping, @DeleteMapping should be in kebab-case.<\/em><\/strong><\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b85\/2a8\/2b4\/b852a82b47574eaa2ddb8777449a3737.png\" alt=\"\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e \u0443 \u0432\u0430\u0441 \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c!\" title=\"\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e \u0443 \u0432\u0430\u0441 \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c!\" width=\"3456\" height=\"1874\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b85\/2a8\/2b4\/b852a82b47574eaa2ddb8777449a3737.png\"\/><\/p>\n<div><figcaption>\u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e \u0443 \u0432\u0430\u0441 \u0432\u0441\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c!<\/figcaption><\/div>\n<\/figure>\n<p>\u0412\u0435\u0441\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 <a href=\"https:\/\/github.com\/LordBarov\/java-sonar-tutorial\/tree\/end\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/823590\/\"> https:\/\/habr.com\/ru\/articles\/823590\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 SonarQube \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043f\u043b\u0430\u0433\u0438\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u043c\u043e\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0434\u0435\u043b\u044e\u0441\u044c \u0441 \u0432\u0430\u043c\u0438 \u0441\u0432\u043e\u0438\u043c \u043e\u043f\u044b\u0442\u043e\u043c \u0438 \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0432\u044b \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u043b\u0430\u0433\u0438\u043d \u0441\u0432\u043e\u0438\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438. <\/p>\n<figure class=\"bordered full-width\"><\/figure>\n<h2>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0432\u0432\u043e\u0434\u043d\u044b\u0435 <\/h2>\n<p>Disclaimer: \u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442 \u043c\u043d\u043e\u0433\u043e\u0435 \u0438\u0437 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e <a href=\"https:\/\/github.com\/SonarSource\/sonar-java\/blob\/master\/docs\/CUSTOM_RULES_101.md\" rel=\"noopener noreferrer nofollow\"><strong>\u0433\u0430\u0439\u0434\u0430<\/strong><\/a>.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0432\u044b\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0433\u043e use-case&#8217;a:<\/p>\n<p><strong><em>\u041d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f MR, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434-\u0441\u0442\u0430\u0439\u043b\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/em><\/strong> <\/p>\n<p>\u0422\u0443\u0442 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 Lint-\u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432<\/h4>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0442\u0430\u043a\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0443\u0436\u0438\u0442\u044c ESLint (\u0434\u043b\u044f JavaScript\/TypeScript) \u0438\u043b\u0438 Checkstyle (\u0434\u043b\u044f Java). \u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u043c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u0412 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0441\u043b\u043e\u0436\u0435\u043d: \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0439\u0442\u0435 \u0441\u0432\u043e\u0439 \u0447\u0435\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0433\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e plugins \u0438\u043b\u0438 extensions.<\/p>\n<p><strong>\u041f\u043b\u044e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041c\u0438\u043d\u0443\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0421\u043b\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u043f\u043e \u0440\u0430\u0437\u043d\u044b\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430\u043c\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0412 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u0434\u043d\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0434\u0440\u0443\u0433\u043e\u0439.<\/p>\n<\/li>\n<\/ul>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SonarQube \u0441 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u043c \u043f\u043b\u0430\u0433\u0438\u043d\u043e\u043c<\/h4>\n<p>\u042d\u0442\u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u043c\u0435\u043d\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u043e\u0434-\u0441\u0442\u0430\u0439\u043b\u0438\u043d\u0433\u043e\u043c \u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c\u044e \u043a\u043e\u0434\u0430, \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u044b \u0432 \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435. SonarQube \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043f\u0440\u043e\u0444\u0438\u043b\u0438.<\/p>\n<p><strong>\u041f\u043b\u044e\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043e\u0434\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u043e\u0431\u043d\u044b\u0439 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u043a\u0440\u0443\u043f\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043c\u0430\u043d\u0434 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u043f\u0440\u043e\u0444\u0438\u043b\u0435\u0439.<\/p>\n<\/li>\n<\/ul>\n<p><strong>\u041c\u0438\u043d\u0443\u0441\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p><strong>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435:<\/strong> SonarQube \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u0434\u043b\u044f \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u0438\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0440\u0435\u0434\u0443<\/h2>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0433\u043e \u0447\u0435\u043a\u0430 \u0441\u043f\u0443\u043b\u0438\u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u0441 \u0433\u0438\u0442\u0445\u0430\u0431\u0430: <a href=\"https:\/\/github.com\/LordBarov\/java-sonar-tutorial\" rel=\"noopener noreferrer nofollow\"><strong>\u0441\u0441\u044b\u043b\u043a\u0430<\/strong><\/a>.<\/p>\n<p>\u042f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u043b \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0430\u0441 \u043e\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0435\u0439 Maven.<\/p>\n<p>\u041f\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 SonarQube, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430 <a href=\"https:\/\/habr.com\/ru\/companies\/ruvds\/articles\/450316\/\" rel=\"noopener noreferrer nofollow\"><strong>TDD<\/strong><\/a><strong> <\/strong>(\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435) \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0430\u0448\u0438\u0445 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0445 \u0447\u0435\u043a\u043e\u0432. \u041b\u0438\u0447\u043d\u043e \u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043f\u043e\u043a\u043b\u043e\u043d\u043d\u0438\u043a\u043e\u043c \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0435\u0431\u044f \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0447\u0435\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043f\u043e\u0441\u043b\u0435 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0432 SonarQube, \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 <strong>CheckVerifier.<\/strong> \u0421 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0433\u043e\u043d\u044f\u0442\u044c \u043d\u0430\u0448\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0435\u0439\u0441\u0430\u0445, \u0447\u0442\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435, \u0447\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u043a\u043e\u0432 \u0432 Mockito.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u0447\u0435\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043b\u0438 URL \u044d\u043d\u0434\u043f\u043e\u0439\u043d\u0442\u043e\u0432 \u0432 <a href=\"https:\/\/medium.com\/@vladimirmorulus\/%D1%81%D0%BF%D1%80%D0%B0%D0%B2%D0%BA%D0%B0-%D0%BF%D0%BE-case-camelcase-kebab-case-pascalcase-snake-case-%D0%B8-%D0%B2%D1%81%D0%B5-case-ecda10463fa8\" rel=\"noopener noreferrer nofollow\">kebab-case<\/a>.<\/p>\n<pre><code class=\"java\">import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping;  public class MyController {      @GetMapping(\"\/kebab-case-url\") \/\/ Compliant     public String getCompliant() {         return \"compliant\";     }      @GetMapping(\"\/camelCaseUrl\") \/\/ Noncompliant     public String getNonCompliant() {         return \"noncompliant\";     }      @PostMapping(\"\/another-kebab-case-url\") \/\/ Compliant     public void postCompliant() {     }      @PostMapping(\"\/AnotherCamelCaseUrl\") \/\/ Noncompliant     public void postNonCompliant() {     }      @PutMapping(\"\/yet-another-kebab-case-url\") \/\/ Compliant     public void putCompliant() {     }      @PutMapping(\"\/YetAnotherCamelCaseUrl\") \/\/ Noncompliant     public void putNonCompliant() {     }      @DeleteMapping(\"\/final-kebab-case-url\") \/\/ Compliant     public void deleteCompliant() {     }      @DeleteMapping(\"\/FinalCamelCaseUrl\") \/\/ Noncompliant     public void deleteNonCompliant() {     } }<\/code><\/pre>\n<h4>\u0412\u0430\u0436\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b \u0442\u0435\u0441\u0442-\u043a\u0435\u0439\u0441\u043e\u0432<\/h4>\n<ol>\n<li>\n<p><strong>\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432:<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412\u0441\u0435 \u0432\u0430\u0448\u0438 \u0442\u0435\u0441\u0442\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438: <code>src\/test\/files\/<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0421\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435 \u043a\u0430\u043a \u043d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0435, \u0442\u0430\u043a \u0438 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0435\u0433\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u043f\u043e\u043c\u0435\u0447\u0430\u0439\u0442\u0435 \u043a\u0430\u043a <code>\/\/ Noncompliant<\/code>, \u0430 \u043f\u043e\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u0435 \u043a\u0430\u043a <code>\/\/ Compliant<\/code>.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u0418\u043c\u043f\u043e\u0440\u0442\u044b:<\/strong><\/p>\n<ul>\n<li>\n<p>\u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u044b. \u0411\u0435\u0437 \u043d\u0438\u0445 \u0442\u0435\u0441\u0442\u044b \u043d\u0435 \u043f\u0440\u043e\u0439\u0434\u0443\u0442 \u0443\u0441\u043f\u0435\u0448\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 kebab-case. <\/p>\n<pre><code class=\"java\">@Rule(key = \"KebabCaseUrlCheck\") public class KebabCaseUrlCheck extends BaseTreeVisitor implements JavaFileScanner {      private static final Pattern KEBAB_CASE_PATTERN = Pattern.compile(\"^(\/[a-z0-9]+(-[a-z0-9]+)*)*$\");      private JavaFileScannerContext context;      @Override     public void scanFile(JavaFileScannerContext context) {         this.context = context;         scan(context.getTree());     }      @Override     public void visitMethod(MethodTree tree) {         List&lt;AnnotationTree> annotations = tree.modifiers().annotations();         for (AnnotationTree annotationTree : annotations) {             TypeTree annotationType = annotationTree.annotationType();             if (annotationType.is(Tree.Kind.IDENTIFIER)) {                 IdentifierTree identifier = (IdentifierTree) annotationType;                 String annotationName = identifier.name();                 if (annotationName.equals(\"GetMapping\") || annotationName.equals(\"PostMapping\") ||                         annotationName.equals(\"PutMapping\") || annotationName.equals(\"DeleteMapping\")) {                     checkUrl(annotationTree);                 }             }         }         super.visitMethod(tree);     }      private void checkUrl(AnnotationTree annotationTree) {         if (annotationTree.arguments().isEmpty()) {             return;         }          Tree argument = annotationTree.arguments().get(0);         if (argument.is(Tree.Kind.ASSIGNMENT)) {             argument = ((org.sonar.plugins.java.api.tree.AssignmentExpressionTree) argument).expression();         }          if (argument.is(Tree.Kind.STRING_LITERAL)) {             LiteralTree literal = (LiteralTree) argument;             String url = literal.value().substring(1, literal.value().length() - 1);              if (!KEBAB_CASE_PATTERN.matcher(url).matches()) {                 context.reportIssue(this, literal, \"The URL should be in kebab-case.\");             }         }     } }<\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <a class=\"mention\" href=\"\/users\/Rule\">@Rule<\/a>(key = &#171;KebabCaseUrlCheck&#187;), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043a\u043b\u044e\u0447 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0432 SonarQube \u0434\u043b\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0447\u0435\u043a\u0430. \u041a\u043b\u0430\u0441\u0441 <strong><em>KebabCaseUrlCheck<\/em><\/strong> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <em>BaseTreeVisitor<\/em> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 JavaFileScanner, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0435\u043c\u0443 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c Java-\u0444\u0430\u0439\u043b\u044b.<\/p>\n<p>\u0428\u0430\u0431\u043b\u043e\u043d \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f URL \u0444\u043e\u0440\u043c\u0430\u0442\u0443 kebab-case \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"java\">private static final Pattern KEBAB_CASE_PATTERN = Pattern.compile(\"^(\/[a-z0-9]+(-[a-z0-9]+))$\");.<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u0447\u0435\u0442\u0430 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445: <\/p>\n<pre><code class=\"java\">private JavaFileScannerContext context;<\/code><\/pre>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u0430 scanFile \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0435\u0440\u0435\u0432\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0444\u0430\u0439\u043b\u0430: <\/p>\n<pre><code class=\"java\">@Override public void scanFile(JavaFileScannerContext context);<\/code><\/pre>\n<p> \u0421\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0437\u043e\u0432\u043e\u043c <\/p>\n<pre><code class=\"java\">scan(context.getTree());<\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <strong><em>visitMethod<\/em><\/strong> \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 \u0444\u0430\u0439\u043b\u0435: <\/p>\n<pre><code class=\"java\"> public void visitMethod(MethodTree tree);<\/code><\/pre>\n<p>\u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430: <\/p>\n<pre><code class=\"java\">List&lt;AnnotationTree> annotations = tree.modifiers().annotations();<\/code><\/pre>\n<p>\u0412 \u0446\u0438\u043a\u043b\u0435 for \u043a\u0430\u0436\u0434\u0430\u044f \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 <code><a class=\"mention\" href=\"\/users\/GetMapping\">@GetMapping<\/a><\/code>, <code><a class=\"mention\" href=\"\/users\/PostMapping\">@PostMapping<\/a><\/code>, <code><a class=\"mention\" href=\"\/users\/PutMapping\">@PutMapping<\/a><\/code> \u0438\u043b\u0438 <code><a class=\"mention\" href=\"\/users\/DeleteMapping\">@DeleteMapping<\/a><\/code>, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 <strong>checkUrl<\/strong>.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <code>checkUrl<\/code> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 URL \u0432 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u041e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0443 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0435\u0442, \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f. \u0417\u0430\u0442\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u043d \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u043c \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u043c. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043a\u0430\u0432\u044b\u0447\u0435\u043a: <\/p>\n<pre><code class=\"java\">String url = literal.value().substring(1, literal.value().length() - 1);<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043b\u0438 URL \u0448\u0430\u0431\u043b\u043e\u043d\u0443 kebab-case: <code>if (!KEBAB_CASE_PATTERN.matcher(url).matches())<\/code>. \u0415\u0441\u043b\u0438 URL \u043d\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u0443, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0447\u0435\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c &#171;The URL should be in kebab-case.&#187;<\/p>\n<h2>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043c\u044b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0442\u0435\u0441\u0442-\u043a\u0435\u0439\u0441\u044b \u0438 \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<br \/>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 <code>src\/test\/java\/org\/sonar\/samples\/java\/checks<\/code>  \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>KebabCaseUrlTest<\/code>  \u0438 \u043f\u0438\u0448\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"java\">package org.sonar.samples.java.checks;  import org.junit.jupiter.api.Test; import org.sonar.java.checks.verifier.CheckVerifier;  public class KebabCaseUrlCheckTest {      @Test     void test() {         CheckVerifier.newVerifier()                 .onFile(\"src\/test\/files\/KebabCaseUrlCheck.java\")                 .withCheck(new KebabCaseUrlCheck())                 .verifyIssues();     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0442\u0435\u0441\u0442 \u0438 \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u043d\u0430\u0448 \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 url \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<h2>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0448\u0442\u0440\u0438\u0445\u0438<\/h2>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u0439\u043c\u0438\u043d\u0433\u0430 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043b\u0430\u0433\u0438\u043d\u0430. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u044d\u0442\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443:<\/p>\n<p><code>src\/main\/java\/org\/sonar\/samples\/java\/MyJavaRulesDefinition.java<\/code> \u0438 \u043c\u0435\u043d\u044f\u0435\u043c \u043f\u043e\u043b\u044f REPOSITORY_KEY \u0438 REPOSITORY_NAME \u043d\u0430 \u043d\u0443\u0436\u043d\u044b\u0435 \u0432\u0430\u043c.<\/p>\n<pre><code class=\"java\">public static final String REPOSITORY_KEY = \"sonar-plugin-habr\"; public static final String REPOSITORY_NAME = \"Habr Guide Plugin\";<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0442\u044c \u043d\u0430\u0448 .jar \u0444\u0430\u0439\u043b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u043f\u043b\u0430\u0433\u0438\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u044d\u0442\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0443: <code>src\/main\/java\/org\/sonar\/samples\/java\/RulesList.java<\/code> <\/p>\n<p>\u0438 \u0432 \u043c\u0435\u0442\u043e\u0434 <code>getJavaChecks<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 KebabCaseUrlCheck.<\/p>\n<pre><code class=\"java\">public static List&lt;Class&lt;? extends JavaCheck>> getJavaChecks() {     return Collections.unmodifiableList(Arrays.asList(             SpringControllerRequestMappingEntityRule.class,             AvoidAnnotationRule.class,             AvoidBrandInMethodNamesRule.class,             AvoidMethodDeclarationRule.class,             AvoidSuperClassRule.class,             AvoidTreeListRule.class,             MyCustomSubscriptionRule.class,             KebabCaseUrlCheck.class,             SecurityAnnotationMandatoryRule.class));   }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-379414","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=379414"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/379414\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=379414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=379414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=379414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}