Skip to content

[FEATURE] Add .shellcheckrc for ShellCheck configuration #116

@WilliamBerryiii

Description

@WilliamBerryiii

IMPORTANT: Before submitting, please remove all sensitive data, secrets, tokens, or confidential information. Ensure you've redacted any NDA-covered information, IP addresses, resource names, or security-related details that shouldn't be publicly disclosed.

Problem Statement

ShellCheck currently runs via MegaLinter without a dedicated configuration file. This means:

  • Shell dialect defaults must be auto-detected per file
  • Optional checks like require-variable-braces are not enabled
  • SC1091 requires 10 individual inline # shellcheck disable= directives across 13 files
  • Direct tool usage outside MegaLinter requires manual flag configuration

Proposed Solution

Create .shellcheckrc configuration file at repository root with project-specific settings:

# ShellCheck configuration for edge-ai repository
shell=bash
source-path=SCRIPTDIR
external-sources=true
enable=require-variable-braces
enable=require-double-brackets
enable=deprecate-which
disable=SC1091

Integrate with MegaLinter by adding to .mega-linter.yml:

BASH_SHELLCHECK_CONFIG_FILE: .shellcheckrc

Alternative Solutions

  • Continue using inline directives (increases maintenance burden)
  • Use only MegaLinter defaults (misses optional checks aligned with bash.instructions.md)

Target Components

  • Terraform modules
  • Bicep modules
  • Blueprints
  • GitHub Actions
  • Documentation
  • Other: MegaLinter configuration, shell scripts

Implementation Ideas

  1. Create .shellcheckrc at repository root
  2. Add BASH_SHELLCHECK_CONFIG_FILE: .shellcheckrc to .mega-linter.yml
  3. Review and remove redundant inline # shellcheck disable=SC1091 directives (10 occurrences)
  4. Validate with shellcheck -x scripts/*.sh

Additional Context

Metric Value
Shell Scripts in Repo 96 files
Shell Dialect 96% Bash
Existing Inline Directives 19 across 13 files

Benefits

  • Enables optional checks aligned with .github/instructions/bash.instructions.md
  • Eliminates 10 redundant inline disable directives
  • Enables direct ShellCheck usage outside MegaLinter
  • Centralizes shell script linting configuration

Potential Challenges

  • May surface new warnings from enabled optional checks (require-variable-braces, require-double-brackets)
  • Some scripts may need updates to comply with stricter rules

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions