<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          IDEA代碼檢測插件,總有一款適合你

          共 2318字,需瀏覽 5分鐘

           ·

          2021-05-14 14:54


          下面提供三個(gè)工具和插件,幫助大家檢測自己的代碼質(zhì)量



          1

          SonarLint

           

          SonarLint 是一個(gè)代碼質(zhì)量檢測插件,可以幫助我們檢測出代碼中的壞味道。


          下載與安裝


          在需要檢測的單個(gè)文件或者單個(gè)項(xiàng)目上右鍵 --> Analyze --> Analyze with SonarLint
          或者選中文件或目錄,點(diǎn)擊菜單欄 Analyze --> Analyze with SonarLint


          我們還可以禁用某些規(guī)則


          如果需要同步自定義的規(guī)則時(shí),可以綁定到 SonarQube




          查看檢測的結(jié)果


          對于代碼中的警告我們不能視而不見


          有了代碼質(zhì)量檢測工具以后,在一定程度上可以保證代碼的質(zhì)量

          對于每一個(gè)問題,SonarLint都給出了示例,還有相應(yīng)的解決方案,教我們怎么修改,極大的方便了我們的開發(fā)

          比如,對于日期類型盡量用LocalDate、LocalTime、LocalDateTime,還有重復(fù)代碼、潛在的空指針異常、循環(huán)嵌套等等問題

          有了代碼規(guī)范與質(zhì)量檢測工具以后,很多東西就可以量化了,比如bug率、代碼重復(fù)率等,還可以自定義各種指標(biāo),方便管理人員查看

          為此,我們需要一個(gè)平臺(tái)來記錄每次檢測分析的結(jié)果,這樣就可以進(jìn)行分析和統(tǒng)計(jì),并且可以直觀的看到這一切

          于是,SonarQube 閃亮登場!



          2

          SonarQube

           

          SonarQube是一個(gè)開源的代碼質(zhì)量管理平臺(tái)





          解壓&本地啟動(dòng)
          https://docs.sonarqube.org/latest/setup/get-started-2-minutes/


          unzip sonarqube-7.7.zip
          cd sonarqube-7.7
          bin/[OS]/sonar.sh consol


          啟動(dòng)成功后,訪問 http://localhost:9000  
          用管理員賬號(admin/admin)登錄


          接下來,為了把檢測的結(jié)果傳到服務(wù)器,我們需要配置一個(gè)Scanner
          https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Maven
          這里我在項(xiàng)目中添加 sonar-maven-plugin 插件


          <build>
              <plugins>
                  <plugin>
                      <groupId>org.sonarsource.scanner.mavengroupId>

                      <artifactId>sonar-maven-pluginartifactId>
                      <version>3.6.0.1398version>
                  plugin>
              plugins>
          build>

          命令行執(zhí)行:mvn clean compile sonar:sonar
          成功后,可以在控制臺(tái)中看到這樣的輸出


          再次刷新 http://localhost:9000/ 會(huì)看到跟剛才不一樣了




          以上只是本地演示,在正式環(huán)境中這些數(shù)據(jù)當(dāng)然要保存到數(shù)據(jù)庫中,具體安裝就不演示了,下面是文檔
          https://docs.sonarqube.org/latest/setup/install-server/
           


          3

          Alibaba代碼規(guī)約插件

           

          阿里代碼規(guī)范,相信大家都不陌生




          這個(gè)無需多言,需要了可以直接安裝插件測試!


          4

          文檔

           

          https://www.sonarqube.org/

          https://www.sonarsource.com/plans-and-pricing/community/

          https://www.sonarlint.org/

          https://docs.sonarqube.org/latest/setup/overview/

          https://docs.sonarqube.org/latest/

          https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-maven

          https://github.com/SonarSource


          文章來源:https://www.cnblogs.com/cjsblog/p/10735800.html


          瀏覽 342
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚洲欧美日韩黄色大片 | 丁香五月社区 | 激情五月丁香色婷婷 | 婷婷色五月天丁香色 | 内射一线天 |