HiveMinds / Productivity-setup

Automatically sets up a productivity setup on Ubuntu 20.04 OS.
GNU Affero General Public License v3.0
2 stars 4 forks source link

Make code shellcheck compliant #15

Open a-t-0 opened 3 years ago

a-t-0 commented 3 years ago
      <p>Cool that you're having a look! Shellcheck is a code-formatting tool meaning it tells you what should be improved about your code style, a bit like python black, except not automated. To use shellcheck you can: <code>sudo apt install shellcheck</code> (on windows you first have to get the WSL app from the store to do that), then you can simply run the shellcheck by cloning this repository and running the shellcheck command from the root directory of this repository. For example:</p>
cd /home/a/
git clone https://github.com/HiveMinds-EU/Productivity-setup.git
cd Productivity-setup
shellcheck -x <filepath>

where the filepath is the relative path to the file your improving, e.g.:

shellcheck -x src/apt_7_0_enable_apt_https_support.sh

Then shellcheck displays the things that could be improved, and tells you how to do that, then you can improve them and run it again, untill shellcheck is silenced for that file. An example that solves the last "shellcheck issue" on line 83 is displayed in the video below:
Alt Text

Here is the list of file todo:

Root directory:

a-t-0 commented 3 years ago
      <p>Pro-tip, apparently this can be done (semi-) automatically:</p>

running the shellcheck command with -f diff (format diff) should produce standardized diff files with all the fixes applied. The only thing you have to do is open this in an editor which supports diff formatting (for example vs code) and check the changes/apply them.