-
Notifications
You must be signed in to change notification settings - Fork 0
/
linting.html
39 lines (37 loc) · 1.97 KB
/
linting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<body>
<p><h1>Linting</h1></p>
<ul>
<li>Linting ⇒ automated check of your code for programmatic and stylistic errors.</li>
<li>This is done by using a tool known as a linter.</li>
<li>A linter is a basic static code analyzer ⇒ it analyzes the code without running it.</li>
<li>The term linting originally comes from a Unix utility for C.</li>
<li>VS Code is prepared for linting and comes with a few linters.</li>
<li>Linters are often used by companies to ensure a certain code standard.</li>
</ul>
<hr />
<p><h1>Linters available in VS Code</h1></p>
<ul>
<li>Pylint - Enforces a soft coding standard.</li>
<li>pycodestyle - Enforces pep8, a much harder coding standard.</li>
<li>PyFlakes - Analyzes programs and detects various errors (Errors that might show up at runtime).</li>
<li>Bandit - Analyzes code to find common security issues.</li>
<li>... a few more.</li>
<li>Flake8 - a combination of PyFlakes and pycodestyle</li>
</ul>
<hr />
<p><h1>Example using Flake8</h1></p>
<img src="https://miketao.oss-cn-shanghai.aliyuncs.com/HTML/html_image/Example_using_Flake8.png" width="60%" height="60%" alt="Example using Flake8"/>
<p><h2>Flake8 found several code style errors in a small program that</h2></p>
<hr />
<p><h1>Turn on Flake8 in VS Code</h1></p>
<img src="https://miketao.oss-cn-shanghai.aliyuncs.com/HTML/html_image/Turn_on_Flake8_in_VSCode.png" width="60%" height="60%" alt="Turn on Flake8 in VS Code"/>
<ul>
<li>You will be using the Command Palette (CP).</li>
<li>You find CP in menu View → Command Palette.</li>
<li>Enable linting: In CP, search for Enable/Disable Linting and switch to Enable.</li>
<li>Enable Flake8: In CP, search for Select Linter and select flake8.</li>
</ul>
<p><h2>Flake8 is applied when you save a file and the result shows up in the Problem terminal.</h2></p>
<p><h2>Interested in code style? Look up the pep8 code guide by the inventor of Python.</h2></p>
</body>
<a href="/index.html">Home</a>