{"id":1286,"date":"2021-05-11T19:30:00","date_gmt":"2021-05-11T10:30:00","guid":{"rendered":"https:\/\/ito-u-oti.com\/?p=1286"},"modified":"2021-05-24T19:55:37","modified_gmt":"2021-05-24T10:55:37","slug":"sonarqube-react-single","status":"publish","type":"post","link":"https:\/\/ito-u-oti.com\/?p=1286","title":{"rendered":"SonarQube\u3068project\u306e\u9023\u643a\u65b9\u6cd5(React + TypeScript)"},"content":{"rendered":"\n<p>create-react-app\u3067\u4f5c\u6210\u3057\u305freact project\b\u3068SonarQube\u3092\u9023\u643a\u3055\u305b\u307e\u3059\u3002<\/p>\n\n\n\n<h2 id=\"outline__1\" class=\"wp-block-heading\">SonarScanner\u306e\u305f\u3081\u306e\u6e96\u5099<\/h2>\n\n\n\n<h3 id=\"outline__1_1\" class=\"wp-block-heading\">\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>sonarqube-scanner\u30fb\u30fb\u30fbSonarQube\u306b\u9759\u7684\u89e3\u6790\u7d50\u679c\u3092\u9001\u4fe1\u3059\u308b<\/li><li>jest-sonar-reporter\u30fb\u30fb\u30fbtest\u7d50\u679c\u3092SonarQube\u7528\u306b\u51fa\u529b\u3059\u308b<\/li><\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nyarn add --dev sonarqube-scanner jest-sonar-reporter\n<\/pre><\/div>\n\n\n<h3 id=\"outline__1_2\" class=\"wp-block-heading\">test report\u306e\u51fa\u529b<\/h3>\n\n\n\n<p>package.json\u3092\u4fee\u6b63\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n...\n&quot;scripts&quot;: {\n  &quot;test&quot;: &quot;react-scripts test --watchAll=false --coverage --testResultsProcessor jest-sonar-reporter&quot;,\n},\n&quot;testResultsProcessor&quot;: &quot;jest-sonar-reporter&quot;,\n&quot;jestSonar&quot;:{\n  &quot;reportPath&quot;:&quot;report&quot;,\n  &quot;reportFile&quot;:&quot;test-report.xml&quot;,\n  &quot;indent&quot;: 4\n},\n...\n<\/pre><\/div>\n\n\n<p>scripts\u306etest<br>\u30ab\u30d0\u30ec\u30c3\u30b8\u306e\u51fa\u529b\u3068jest-sonar-reporter\u3067\u306e\u30ec\u30dd\u30fc\u30c8\u51fa\u529b\u3092\u6307\u5b9a<\/p>\n\n\n\n<p>testResultsProcessor<br>\u4f7f\u7528\u3059\u308b\u30ec\u30dd\u30fc\u30c8\u51fa\u529b\u30d7\u30ed\u30bb\u30c3\u30b5\u3092\u6307\u5b9a<\/p>\n\n\n\n<p>jestSonar<br>\u30ec\u30dd\u30fc\u30c8\u306e\u51fa\u529b\u5148\u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u3002<br>report\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306btest-report.xml\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u51fa\u529b\u3059\u308b<\/p>\n\n\n\n<h3 id=\"outline__1_3\" class=\"wp-block-heading\">eslint report\u306e\u51fa\u529b<\/h3>\n\n\n\n<p>package.json\u3092\u4fee\u6b63\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&quot;scripts&quot;: {\n  &quot;lint&quot;: &quot;yarn eslint --ext .js,.jsx,.ts,.tsx -f json -o .\/report\/eslint-report.json&quot;\n},\n<\/pre><\/div>\n\n\n<p>report\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306beslint-report.json\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u51fa\u529b\u3059\u308b<\/p>\n\n\n\n<h3 id=\"outline__1_4\" class=\"wp-block-heading\">\u78ba\u8a8d<\/h3>\n\n\n\n<p>script\u3092\u5b9f\u884c\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u3089\u308c\u308b\u3053\u3068<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nyarn test\nyarn lint\n<\/pre><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"224\" height=\"80\" src=\"https:\/\/ito-u-oti.com\/wp-content\/uploads\/2021\/05\/image-20.png\" alt=\"\" class=\"wp-image-1288\"\/><\/figure>\n\n\n\n<p>\u307e\u305f\u3001coverage\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e2d\u306blcov.info\u30d5\u30a1\u30a4\u30eb\u304c\u3067\u304d\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 id=\"outline__2\" class=\"wp-block-heading\">SonarScanner\u306e\u8a2d\u5b9a<\/h2>\n\n\n\n<p>\u30eb\u30fc\u30c8\u306bsonar-scanner.js\u3092\u4f5c\u6210\u3059\u308b<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nconst scanner = require('sonarqube-scanner');\nscanner(\n    {\n        serverUrl: &quot;http:\/\/localhost:9000&quot;,\n        options: {\n            &quot;sonar.login&quot;: &quot;admin&quot;,\n            &quot;sonar.password&quot;: &quot;password&quot;,\n            &quot;sonar.projectKey&quot;: 'com.example.yourproject:react-template',\n            &quot;sonar.projectName&quot;: 'react-template',\n            &quot;sonar.language&quot;: &quot;js&quot;,\n            &quot;sonar.sourceEncoding&quot;: &quot;UTF-8&quot;,\n            &quot;sonar.sources&quot;: &quot;.\/src&quot;,\n            &quot;sonar.tests&quot;: &quot;.\/src&quot;,\n            &quot;sonar.test.inclusions&quot;: &quot;**\/*.test.tsx,**\/*.test.ts&quot;,\n\n            &quot;sonar.eslint.reportPaths&quot;: &quot;report\/eslint-report.json&quot;,\n            &quot;sonar.testExecutionReportPaths&quot;: &quot;report\/test-report.xml&quot;,\n            &quot;sonar.typescript.lcov.reportPaths&quot;: &quot;coverage\/lcov.info&quot;,\n\n            &quot;sonar.exclusions&quot;: &quot;.\/node_modules&quot;,\n            &quot;sonar.exclusions&quot;: &quot;**\/build\/**&quot;,\n            &quot;sonar.exclusions&quot;: &quot;**\/test\/**&quot;,\n        },\n    },\n    () =&gt; process.exit()\n);\n<\/pre><\/div>\n\n\n<p>package.json\u3092\u4fee\u6b63\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&quot;scripts&quot;: {\n  &quot;sonar&quot;: &quot;node sonarqube-scanner.js&quot;\n},\n<\/pre><\/div>\n\n\n<h2 id=\"outline__3\" class=\"wp-block-heading\">\u5b9f\u884c<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nyarn sonar\n<\/pre><\/div>\n\n\n<p>sonar-scanner\u306e\u5b9f\u614b\u304cDL\u3055\u308c\u3001<br>SUCCESS\u3059\u308b\u3068SonarQube\u306b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"990\" height=\"157\" src=\"https:\/\/ito-u-oti.com\/wp-content\/uploads\/2021\/05\/image-21.png\" alt=\"\" class=\"wp-image-1289\"\/><\/figure>\n\n\n\n<h2 id=\"outline__4\" class=\"wp-block-heading\">\u30c8\u30e9\u30d6\u30eb\u30b7\u30e5\u30fc\u30c6\u30a3\u30f3\u30b0<\/h2>\n\n\n\n<h3 id=\"outline__4_1\" class=\"wp-block-heading\">sonar-scanner\u306e\u5b9f\u884c\u3067DL\u3059\u308b\u3068\u3053\u308d\u3067\u6b62\u307e\u308b<\/h3>\n\n\n\n<p>proxy\u3068\u304b\u3067\u5916\u90e8\u306e\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u306b\u51fa\u308c\u306a\u3044\u6642\u3068\u304b\u306b\u8d77\u304d\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h4 id=\"outline__4_1_1\" class=\"wp-block-heading\">\u8a3c\u660e\u66f8\u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3059\u308b<\/h4>\n\n\n\n<p>node\u306e\u5b9f\u884c\u6642\u306b\u8a3c\u660e\u66f8\u30a8\u30e9\u30fc\u3068\u306a\u308b\u30d1\u30bf\u30fc\u30f3<br>\u8a3c\u660e\u66f8\u30d5\u30a1\u30a4\u30eb\u304c\u300cproxyCerts.crt\u300d\u3068\u3057\u305f\u6642\u306b<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nNODE_EXTRA_CA_CERTS=~\/proxyCerts.crt  node sonarqube-scanner.js\n<\/pre><\/div>\n\n\n<p>\u3067\u5b9f\u884c\u3067\u304d\u308b\u3002<\/p>\n\n\n\n<p>package.json\u306escript\u306b\u3053\u306e\u307e\u307e\u66f8\u3044\u3066\u3082\u3044\u3044\u304b\u3068\u3002<\/p>\n\n\n\n<h4 id=\"outline__4_1_2\" class=\"wp-block-heading\">\u624b\u52d5\u3067\u683c\u7d0d\u3059\u308b<\/h4>\n\n\n\n<p>\u5b9f\u884c\u30ed\u30b0\u306b\u51fa\u3066\u3044\u308b\u3053\u3068\u3092\u624b\u52d5\u3067\u3084\u308b\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/\">https:\/\/binaries.sonarsource.com\/Distribution\/sonar-scanner-cli\/<\/a><br>\u3053\u3053\u304b\u3089zip\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u6240\u5b9a\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\u3057\u3066\u5c55\u958b\u3057\u307e\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ncd ~\/.sonar\/native-sonar-scanner\nunzip sonar-scanner-cli-4.5.0.2216-osname.zip\n<\/pre><\/div>\n\n\n<h2 id=\"outline__5\" class=\"wp-block-heading\">\u95a2\u9023<\/h2>\n\n\n\n<p><a href=\"https:\/\/ito-u-oti.com\/docker-sonarqube\/\">Docker\u3067SonarQube\u74b0\u5883\u69cb\u7bc9\u3092\u624b\u65e9\u304f\u69cb\u7bc9\u3059\u308b<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/ito-u-oti.com\/sonarqube-gradle\/\">SonarQube\u3068project\u306e\u9023\u643a\u65b9\u6cd5(Spring Boot,gradle)<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/ito-u-oti.com\/sonarqube-qualitygate-api\/\">SonarQube\u3067\u7ba1\u7406\u3057\u3066\u3044\u308bproject\u306eQualityGate\u306e\u72b6\u614b\u3092API\u3067\u53d6\u5f97\u3059\u308b\u65b9\u6cd5<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/ito-u-oti.com\/sonarqube-react-monorepo\/\">SonarQube\u3068project\u306e\u9023\u643a\u65b9\u6cd5(monorepo+React + TypeScript)<\/a><\/p>\n\n\n\n<h2 id=\"outline__6\" class=\"wp-block-heading\">\u53c2\u8003<\/h2>\n\n\n\n<p><a href=\"https:\/\/javascript.plainenglish.io\/how-to-set-up-sonarqube-locally-on-a-react-typescript-project-ec02cd8e2626\">How to set up SonarQube locally on a React TypeScript Project<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/www.zu-min.com\/archives\/505\">Node.js \u3067\u4e2d\u9593\u8a3c\u660e\u66f8\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044 Web \u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>create-react-app\u3067\u4f5c\u6210\u3057\u305freact project\b\u3068SonarQube\u3092\u9023\u643a\u3055\u305b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1263,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[286],"tags":[295,287,296,283],"class_list":["post-1286","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sonarqube","tag-react-js","tag-sonarqube","tag-typescript","tag-yarn"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/1286","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1286"}],"version-history":[{"count":4,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/1286\/revisions"}],"predecessor-version":[{"id":1338,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/1286\/revisions\/1338"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/media\/1263"}],"wp:attachment":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}