mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-08 05:03:46 -05:00
build: lint for typos
This commit is contained in:
@@ -43,6 +43,11 @@ repos:
|
||||
files: \.(yaml|yml)$
|
||||
entry: yamllint --strict --config-file .yamllint.yml
|
||||
|
||||
- repo: "https://github.com/crate-ci/typos"
|
||||
rev: v1.16.8
|
||||
hooks:
|
||||
- id: typos
|
||||
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: poetry-check
|
||||
|
||||
2
.typos.toml
Normal file
2
.typos.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[default.extend-words]
|
||||
nd = "nd" # Used in the context of '2nd'
|
||||
@@ -290,7 +290,7 @@ Functions for string manipulation
|
||||
- **`_ltrim_`** Removes all leading whitespace (from the left)
|
||||
- **`_regexCapture_`** Use regex to validate and parse strings
|
||||
- **`_rtrim_`** Removes all leading whitespace (from the right)
|
||||
- **`_splitString_`** Split a string based on a given delimeter
|
||||
- **`_splitString_`** Split a string based on a given delimiter
|
||||
- **`_stringContains_`** Tests whether a string matches a substring
|
||||
- **`_stringRegex_`** Tests whether a string matches a regex pattern
|
||||
- **`_stripANSI_`** Strips ANSI escape sequences from text
|
||||
@@ -310,7 +310,7 @@ Functions required to allow the script template and alert functions to be used
|
||||
|
||||
- Function names use camel case surrounded by underscores: `_nameOfFunction_`
|
||||
- Local variable names use camel case with a starting underscore: `_localVariable`
|
||||
- Global variables are in ALL_CAPS with underscores seperating words
|
||||
- Global variables are in ALL_CAPS with underscores separating words
|
||||
- Exceptions to the variable an function naming rules are made for alerting functions and colors to ease my speed of programming. (Breaking years of habits is hard...) I.e. `notice "Some log item: ${blue}blue text${reset}` Where `notice` is a function and `$blue` and `$reset` are global variables but are lowercase.
|
||||
- Variables are always surrounded by quotes and brackets `"${1}"` (Overly verbose true, but a safe practice)
|
||||
- Formatting is provided by [shfmt](https://github.com/mvdan/sh) using 4 spaces for indentation
|
||||
|
||||
22
poetry.lock
generated
22
poetry.lock
generated
@@ -503,6 +503,26 @@ files = [
|
||||
{file = "tomlkit-0.12.1.tar.gz", hash = "sha256:38e1ff8edb991273ec9f6181244a6a391ac30e9f5098e7535640ea6be97a7c86"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typos"
|
||||
version = "1.16.8"
|
||||
description = "Source Code Spelling Correction"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "typos-1.16.8-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:b4d0bf1728ff35849690c956b0c8f01f6cf00a86d4d76a2fcecda808345417bf"},
|
||||
{file = "typos-1.16.8-py3-none-macosx_11_0_arm64.whl", hash = "sha256:0155e64c26074aec76dabd5e716334aae6cef16371e6457536a7b27be638200e"},
|
||||
{file = "typos-1.16.8-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc2b8831dfae748a831962036aa325d3a6cf339dbf397969779d31381b33081f"},
|
||||
{file = "typos-1.16.8-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:902c501e9527ceffd43f3f78356ae0c8e0f4e013981438cce91c56fe55fc4b7f"},
|
||||
{file = "typos-1.16.8-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f4ac08d8de1a1657bbe8467afa41776bd7d5991112543cd9337d120185f8b945"},
|
||||
{file = "typos-1.16.8-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b3f3f714b03bad7d48b416b218be13395a5980ca1dd71f3e45f22ca0f7b2d44e"},
|
||||
{file = "typos-1.16.8-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1e31ea1b36e3860a16e399dacc2584a08fa4114a8f8d1520d7740ddbe1fad28a"},
|
||||
{file = "typos-1.16.8-py3-none-win32.whl", hash = "sha256:3df2e208e0a6385c9f1c990c7222ec2067e499162a7a6c615c0e730deadef4c8"},
|
||||
{file = "typos-1.16.8-py3-none-win_amd64.whl", hash = "sha256:a9a1ed3107c05f34045f2e697c6cdb339a15411ccfc4dd1358cf18d6c684d4a7"},
|
||||
{file = "typos-1.16.8.tar.gz", hash = "sha256:362b1238729eb8644cf9ece59886a40e7ef01eaaf4ff4910e511cb9cf97d5f21"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "virtualenv"
|
||||
version = "20.24.3"
|
||||
@@ -574,4 +594,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "d26a03f9429c641f0c78f670697c58eae05369c75bcc6d2866f1f0ca8e97db53"
|
||||
content-hash = "54e105b0b6c5998507ab75393f875db4856f3ceb20820c8cf298640d76058b1a"
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
commitizen = "^3.7.0"
|
||||
pre-commit = "^3.3.3"
|
||||
python = "^3.11"
|
||||
typos = "^1.16.8"
|
||||
yamllint = "^1.32.0"
|
||||
|
||||
[build-system]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# format \b[word]\b where '\b' is a word delimeter
|
||||
# format \b[word]\b where '\b' is a word delimiter
|
||||
# format //gI where the 'I' is case insensitivity. Only works in gnu-sed.
|
||||
s/\ba\b//gI
|
||||
s/\bable\b//gI
|
||||
|
||||
@@ -92,7 +92,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "_commandExists_: false" {
|
||||
run _commandExists_ "someNonexistantBinary"
|
||||
run _commandExists_ "someNonexistentBinary"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
|
||||
@@ -302,10 +302,10 @@ _testParseYAML_() {
|
||||
}
|
||||
|
||||
@test "_sourceFile_ failure" {
|
||||
run _sourceFile_ "someNonExistantFile"
|
||||
run _sourceFile_ "someNonExistentFile"
|
||||
|
||||
assert_failure
|
||||
assert_output --partial "[ fatal] Attempted to source 'someNonExistantFile'. Not found"
|
||||
assert_output --partial "[ fatal] Attempted to source 'someNonExistentFile'. Not found"
|
||||
}
|
||||
|
||||
@test "_sourceFile_ success" {
|
||||
|
||||
@@ -80,23 +80,23 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "_execute_: Bad command" {
|
||||
run _execute_ "rm nonexistant.txt"
|
||||
run _execute_ "rm nonexistent.txt"
|
||||
|
||||
assert_failure
|
||||
assert_output --partial "[warning] rm nonexistant.txt"
|
||||
assert_output --partial "[warning] rm nonexistent.txt"
|
||||
}
|
||||
|
||||
@test "_execute_ -e: Bad command" {
|
||||
run _execute_ -e "rm nonexistant.txt"
|
||||
run _execute_ -e "rm nonexistent.txt"
|
||||
|
||||
assert_failure
|
||||
assert_output "error: rm nonexistant.txt"
|
||||
assert_output "error: rm nonexistent.txt"
|
||||
}
|
||||
|
||||
@test "_execute_ -p: Return 0 on bad command" {
|
||||
run _execute_ -p "rm nonexistant.txt"
|
||||
run _execute_ -p "rm nonexistent.txt"
|
||||
assert_success
|
||||
assert_output --partial "[warning] rm nonexistant.txt"
|
||||
assert_output --partial "[warning] rm nonexistent.txt"
|
||||
}
|
||||
|
||||
@test "_execute_: Good command" {
|
||||
|
||||
@@ -8,7 +8,7 @@ _backupFile_() {
|
||||
# $1 (Required) - Source file
|
||||
# $2 (Optional) - Destination dir name used only with -d flag (defaults to ./backup)
|
||||
# OPTS:
|
||||
# -d - Move files to a backup direcory
|
||||
# -d - Move files to a backup directory
|
||||
# -m - Replaces copy (default) with move, effectively removing the original file
|
||||
# REQUIRES:
|
||||
# _execute_
|
||||
@@ -84,7 +84,7 @@ _createUniqueFilename_() {
|
||||
# filenames by incrementing a number at the end of the filename
|
||||
# ARGS:
|
||||
# $1 (Required) - Name of file to be created
|
||||
# $2 (Optional) - Separation characted (Defaults to a period '.')
|
||||
# $2 (Optional) - Separation character (Defaults to a period '.')
|
||||
# OUTS:
|
||||
# stdout: Unique name of file
|
||||
# 0 if successful
|
||||
|
||||
@@ -307,9 +307,9 @@ _splitString_() (
|
||||
|
||||
declare -a _arr=()
|
||||
local _input="${1}"
|
||||
local _delimeter="${2}"
|
||||
local _delimiter="${2}"
|
||||
|
||||
IFS="${_delimeter}" read -r -a _arr <<<"${_input}"
|
||||
IFS="${_delimiter}" read -r -a _arr <<<"${_input}"
|
||||
|
||||
printf '%s\n' "${_arr[@]}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user