LGTM/it: Difference between revisions

From FreeCAD Documentation
(Created page with "[https://www.lgtm.com LGTM] è uno strumento di analisi del codice che può essere integrato in più sistemi di controllo della versione del software online e supporta diverse...")
(Created page with "LGTM è adatto come strumento di analisi del codice per lo sviluppo di ambienti di lavoro di FreeCAD in Python e altri progetti di dimensioni medio-piccole. Questa pagina offr...")
Line 5: Line 5:
[https://www.lgtm.com LGTM] è uno strumento di analisi del codice che può essere integrato in più sistemi di controllo della versione del software online e supporta diverse lingue. È un eccellente controllore della qualità del codice, che identifica i problemi del codice che spesso non vengono individuati da altri controllori del codice e linters.
[https://www.lgtm.com LGTM] è uno strumento di analisi del codice che può essere integrato in più sistemi di controllo della versione del software online e supporta diverse lingue. È un eccellente controllore della qualità del codice, che identifica i problemi del codice che spesso non vengono individuati da altri controllori del codice e linters.


LGTM è adatto come strumento di analisi del codice per lo sviluppo di ambienti di lavoro di FreeCAD in Python e altri progetti di dimensioni medio-piccole. Questa pagina offre una panoramica di come iniziare a usare LGTM con un ambiente di lavoro di FreeCAD in Python.
LGTM is well-suited as a code-analysis tool for developing FreeCAD Python workbenches and other small-to-mid-sized projects. This page provides an overview of how to get started using LGTM with a FreeCAD Python Workbench.


== Getting Started ==
== Getting Started ==

Revision as of 17:22, 20 October 2019

Other languages:

Descrizione

LGTM è uno strumento di analisi del codice che può essere integrato in più sistemi di controllo della versione del software online e supporta diverse lingue. È un eccellente controllore della qualità del codice, che identifica i problemi del codice che spesso non vengono individuati da altri controllori del codice e linters.

LGTM è adatto come strumento di analisi del codice per lo sviluppo di ambienti di lavoro di FreeCAD in Python e altri progetti di dimensioni medio-piccole. Questa pagina offre una panoramica di come iniziare a usare LGTM con un ambiente di lavoro di FreeCAD in Python.

Getting Started

Getting started with LGTM depends on the online version control platform you're using. The LGTM documentation for automated code review provides a good overview of how to get LGTM integrated into your project for several platforms.

In addition it's possible to do a wide range of in-depth analyses of code on LGTM, which is beyond the scope of this tutorial. You can read more about that in the LGTM documentation on configuring code analysis.

Getting Results

Once you've set up LGTM and provided access to your code repositories, analyses are typically done daily on the repository. So, pushed changes will not yeild results immediately. It is possible to have LGTM analyze pull requests when they are submitted, as described in the LGTM documentation.

Reviewing the results simply requires logging in to your LGTM dashboard and selecting the desired project. From there, code analyses will provide a list of issues (like bugs, bad coding practices, useless/irrelevant/unused code, etc.) for your perusal. In addition LGTM provides overall code 'ratings' (A, B, C, D) depending on the number of issue you have compared to the overall size of your project.

Probably, the most useful, immediate way to manage the results of your code analysis is simply filtering out files in your project that you don't want analyzed. That is, suppose you're developing new code that is incomplete, keeping around legacy code that is otherwise unused, or have a good deal of testing code that doesn't need analysis. LGTM provides file classification, an easy way to filter those files so they don't pollute your analysis results.

To enable file classification, first create a file named ".lgtm.yml" in your projects top-most directory. Then, in that file, add some classifications.

Below is an example from the FreeCAD Trails Python workbench:

path_classifiers:
  template:
    - freecad/trails/resources
    - freecad/trails/project/commands/command_template.py
    - freecad/trails/init_gui.py
 
  test:
    - freecad/trails/project/commands/spiral_test.py
    - freecad/trails/TestFPO.py
 
  legacy:
    - freecad/trails/corridor/loft
    - freecad/trails/alignment/VerticalAlignment.py
    - freecad/trails/alignment/VerticalCurve.py
    - freecad/trails/alignment/GenerateVerticalAlignment.py
    - freecad/trails/alignment/ImportVerticalCurve.py
    - freecad/trails/corridor/template/TemplateLibrary.py

Note that indent levels are important in LGTM. Incorrect indenting will result in failed file classification.

Also, some classifications (like 'template' and 'test') are used by LGTM for queries and other analysis components. You may also define your own custom tags, which will filter code and provide additional queryable results.