Skip to content

Commit

Permalink
line length
Browse files Browse the repository at this point in the history
  • Loading branch information
woensug-choi committed May 31, 2024
1 parent 48afa58 commit 8db8afe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,12 @@ repos:
language: system
types: [text]
files: \.(xacro|urdf|sdf|xml|launch)$

- repo: local
hooks:
- id: check-line-length-under-100
name: Check line length
description: Ensure no line is longer than 100 characters.
entry: bash -c 'if (( $(awk "{ if (length > 100) print }" $1 | wc -l) > 0 )); then echo "Line too long in file $1"; exit 1; fi'
language: system
files: .
15 changes: 11 additions & 4 deletions extras/lint_local/lint_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ done

# Check if Python 3 is installed before checking Python packages
if ! command -v python3 &>/dev/null; then
echo -e "\033[31mPython is not installed. Install it to proceed with Python package checks.\033[0m"
echo -e "\033[31mPython is not installed. Install to proceed.\033[0m"
else
echo "Checking Python dependencies to run lints..."

Expand All @@ -69,11 +69,17 @@ if [ "$all_dependencies_installed" = true ]; then
find . -iname '*.cpp' -o -iname '*.h' | xargs clang-format -i

echo -e "\033[32m[3/6] ========= Linting XML files ===========\033[0m"
find . \( -iname '*.urdf' -o -iname '*.sdf' -o -iname '*.xacro' -o -iname '*.xml' -o -iname '*.launch' \) -print0 | xargs -0 xmllint --noout
find . \( -iname '*.urdf' -o -iname '*.sdf' -o -iname '*.xacro' \
-o -iname '*.xml' -o -iname '*.launch' \) -print0 | xargs -0 xmllint --noout

echo -e "\033[32m[4/6] ========= Running ShellCheck ===========\033[0m"
# shellcheck disable=SC2038
find . -iname '*.sh' | xargs shellcheck
find . -iname '*.sh' | while read -r file; do
awk '{ if (length($0) > 100) \
printf "\033[31mError in file %s: Line %d is %d characters long \
(should be under 100):\n%s\n\033[0m", \
FILENAME, NR, length($0), $0 }' "$file"
done

echo -e "\033[32m[5/6] ========= Linting YAML files ===========\033[0m"
find . \( -iname '*.yml' -o -iname '*.yaml' \) -print0 | xargs -0 yamllint
Expand All @@ -84,5 +90,6 @@ if [ "$all_dependencies_installed" = true ]; then
# shellcheck disable=SC2028
echo "\033[32mAll linting processes completed. Awesome!\033[0m"
else
echo -e "\033[31mNot all dependencies are installed. Please install the missing packages before proceeding.\033[0m"
echo -e "\033[31mNot all dependencies are installed. \
Please install the missing packages before proceeding.\033[0m"
fi
2 changes: 2 additions & 0 deletions extras/ros-jazzy-gz-harmonic-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ sudo apt install -y \
echo "Installation complete!"

sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
# shellcheck disable=SC1091
# shellcheck disable=SC2086
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2-testing/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list >/dev/null
sudo wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/gazebo-stable.list >/dev/null
Expand Down

0 comments on commit 8db8afe

Please sign in to comment.