Page:
Scripting Coding Convention
Pages
API SMHI
API TimeEdit
Accessibility Testing
Api documentation
Bat/Ps
Branch Creation
C# Coding Convention
CSS Coding Convention
Coding Conventions
Creating new databases
Dapper
Documentation for service endpoints
Documentation of useTemperature and mock sensor
Energy endpoints
Environment
Evaluation react-grid-layout
Evaluation Localization
Evaluation Password hashing
Evaluation Testing framework
Evaluation of Logging Frameworks
Formatter
Frontend model
Generic Diagram for Sensor data flow
Home
How to- Creating Databases in Docker
Implementing different Styles
Implementing new Mockup sensors
Implementing new Views
Installation script documentation
Installation
Issues
JSON Coding Convention
Jest Testing
Layout endpoints
Linux
Localization
Login endpoints
Mac
Middleware model
Mock API Ceation Guidelines
Mockup models
Model Tools and Standards
Parking endpoints
React/JavaScript Coding Convention
React
Reviews
Room booking endpoints
SQL Coding Convention
Scheduled Database tasks
Scripting Coding Convention
Secrets and .env
Server Access
Server-Deployment
Service/API models
System models
System requirements
Temperature endpoints
Testing API with Bruno
Testing Architecture
Testing frontend for Mobile devices
Testing frontend with Playwright
Testing methodology
Västtrafik API
Webpage Design
Windows
pg_cron and scheduled database jobs
xUnit Testing
No results
1
Scripting Coding Convention
Tim Svensson edited this page 2026-04-24 13:07:22 +00:00
Table of Contents
Scripting Coding Convention
General
- Indentation is explicitly made with two spaces instead of using tab.
- Comments should be short and descriptive.
- Filenames follow the naming convention PascalCase followed by their extension (e.g., BuildScript.sh).
- Functions should have a comment that describes what the function does.
To avoid cluttering the script should also try to group belonging commands together and add space(s) between other groups. Example:
# Movies dir
cd ./movies
ffmpeg -i input1.mp4 -c:v libx265 -crf 25 -preset fast -pix_fmt yuv420p10le -c:a libopus -b:a 96k output1.mkv
ffmpeg -i input2.mp4 -c:v libx265 -crf 25 -preset fast -pix_fmt yuv420p10le -c:a libopus -b:a 96k output2.mkv
ffmpeg -i input3.mp4 -c:v libx265 -crf 25 -preset fast -pix_fmt yuv420p10le -c:a libopus -b:a 96k output3.mkv
cd ..
# Shows dir
cd ./shows
ffmpeg -i input.mp4 -c:v libx265 -crf 25 -preset fast -pix_fmt yuv420p10le -c:a libopus -b:a 96k output.mkv
cd ..
Bash
- The max length of a line should not extend 80 characters.
- The script should always use the .sh extension.
- Bash use snake_case for its variable names (e.g., some_variable).
- Commenting in Bash is done with a "#" character followed by a space.
- Bash scripts should always start with:
#!/bin/bash
#
# Description of what the script does
- Functions should use the same naming style as variables (snake_case) and use $1, $2, etc. for parameters.
- Comparisons don't usually need quotes, but can be used to avoid bugs with variables having spaces in them. Otherwise if-statments only need to end with "fi":
dependency_missing=false
# dependency_missing don't need quotes since it's a boolean
if $dependency_missing; then
echo "Missing dependencies"
exit 1
fi
Batch
- Batch scripts use the .bat extention.
- Batch use camelCase for its variable names (e.g., someVariable).
- Commenting in Batch is done with two ":" characters followed by NO space.
- Functions should use the same naming style as variables (camelCase) and use $1, $2, etc. for parameters.
- Comparisons in Batch uses quotes even if it isn't a string, variables are put between '!'s or '%'s. Example:
if "!dependencyMissing!"=="true" (
::Something happens
)
or
if "%dependencyMissing%"=="true" (
::Something happens
)
1. Setup
2. Standards
- Coding Conventions
- Issues
- Branch creation
- Reviews
- Implementation Standards
- [WIP] Creating new databases
- Localization
3. Models and Diagrams
4. Testing
5. Documentation
- Documentation for service endpoints
- API documentation
- Webpage Design
- Secrets and .env
- Evaluations
- Installation and Rebuild script documentation
6. Guides and How-to's
7. Micro Service Mockup Api
- Guidelines Mircro Service Mockup
- Documentation of useTemperature/useTemperatureTimeSeries mockup sensor