Contents
lint- detects and corrects bad coding practices in Stata do-files.
Syntax
lint “input_file” [using “output_file”] , [options]
The lint command can be broken into two functionalities:
1. Detection identifies bad coding practices in a Stata do-files
2. Correction corrects bad coding practices in a Stata do-file.
If an output_file is specified with using, then the linter will apply the Correction functionality and will write a new file with corrections. If not, the command will only apply the Detection functionality, returning a report of suggested corrections and potential issues of the do-file in Stata’s Results window. Users should note that not all the bad practices identified in Detection can be amended by Correction.
For this command to run, you will need Stata version 16 or greater, Python, and the Python package Pandas installed. To install Python and integrate it with Stata, refer to this page. To install Python packages, refer to this page.
Options Description
- verbose: Report bad practices and issues found on each line of the do-file.
- nosummary: Suppress summary table of bad practices and potential issues.
- indent(integer): Number of whitespaces used when checking indentation coding practices (default: 4).
- space(integer): Number of whitespaces used instead of hard tabs when checking indentation practices (default: same as indent).
- linemax(integer): Maximum number of characters in a line when checking line extension practices (default: 80).
- excel(filename): Save an Excel file of line-by-line results.
- force: Allow the output file name to be the same as the name of the input file; overwriting the original do-file. The use of this option is not recommended because it is slightly possible that the corrected do-file created by the command will break something in your code and you should always keep a backup of it.
- automatic: Correct all bad coding practices without asking if you want each bad coding practice to be corrected or not. By default, the command will ask the user about each correction interactively after producing the summary report.
- replace: Overwrite any existing output file.