Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .codacy/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ version_file="$CODACY_CLI_V2_TMP_FOLDER/version.yaml"

get_version_from_yaml() {
if [ -f "$version_file" ]; then
local version=$(grep -o 'version: *"[^"]*"' "$version_file" | cut -d'"' -f2)
local version
version=$(grep -o 'version: *"[^"]*"' "$version_file" | cut -d'"' -f2)
if [ -n "$version" ]; then
echo "$version"
return 0
Expand All @@ -55,7 +56,8 @@ get_latest_version() {
fi

handle_rate_limit "$response"
local version=$(echo "$response" | grep -m 1 tag_name | cut -d'"' -f4)
local version
version=$(echo "$response" | grep -m 1 tag_name | cut -d'"' -f4)
echo "$version"
}

Expand Down Expand Up @@ -146,4 +148,4 @@ if [ "$#" -eq 1 ] && [ "$1" = "download" ]; then
echo "Codacy cli v2 download succeeded"
else
eval "$run_command $*"
fi
fi
4 changes: 2 additions & 2 deletions .github/instructions/codacy.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Configuration for AI behavior when interacting with Codacy's MCP Server
- Wait for the user to respond before proceeding with any other actions

## After every response
- If you made any file edits in this conversation, verify you ran `codacy_cli_analyze` tool from Codacy's MCP Server
- If you made any file edits in this conversation, verify you ran `codacy_cli_analyze` tool from Codacy's MCP Server

## When there are no Codacy MCP Server tools available, or the MCP Server is not reachable
- Suggest the user the following troubleshooting steps:
Expand Down Expand Up @@ -69,4 +69,4 @@ Configuration for AI behavior when interacting with Codacy's MCP Server
- If the user accepts, run the `codacy_setup_repository` tool
- Do not ever try to run the `codacy_setup_repository` tool on your own
- After setup, immediately retry the action that failed (only retry once)
---
---
20 changes: 10 additions & 10 deletions .github/workflows/quality-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install markdownlint
run: npm install --global [email protected]

Expand All @@ -26,7 +26,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Validate PowerShell scripts
run: |
# Find PowerShell scripts and validate syntax
Expand All @@ -36,13 +36,13 @@ jobs:
# pwsh -NoProfile -NonInteractive -Command "& { try { [System.Management.Automation.PSParser]::Tokenize((Get-Content '$script' -Raw), [ref]\$null) | Out-Null; Write-Host 'OK: $script' } catch { Write-Error 'SYNTAX ERROR in $script: $_'; exit 1 } }"
done
continue-on-error: true

- name: Validate Python scripts
run: |
# Install Python and check syntax
python3 -m py_compile $(find . -name "*.py" -type f) || true
continue-on-error: true

- name: Validate Bash scripts
run: |
# Check bash scripts with shellcheck if available
Expand All @@ -59,11 +59,11 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Validate repository structure
run: |
echo "Checking repository structure..."

# Check for required top-level files
required_files=("README.md" "LICENSE" "INSTRUCTIONS.md" "CONTRIBUTING.md")
for file in "${required_files[@]}"; do
Expand All @@ -74,7 +74,7 @@ jobs:
echo "✓ Found: $file"
fi
done

# Check for expected language directories
expected_dirs=("Bash" "Go" "JavaScript" "PowerShell" "Python" "Ruby")
for dir in "${expected_dirs[@]}"; do
Expand All @@ -84,7 +84,7 @@ jobs:
echo "✓ Found: $dir/"
fi
done

# Check category structure within language directories
categories=("automation" "data-processing" "miscellaneous" "networking" "system-administration" "text-processing" "web-scraping")
for lang_dir in "${expected_dirs[@]}"; do
Expand All @@ -96,5 +96,5 @@ jobs:
done
fi
done
echo "Repository structure validation complete"

echo "Repository structure validation complete"
11 changes: 9 additions & 2 deletions .markdownlint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@
"MD033": {
"allowed_elements": ["br", "details", "summary"]
},
"MD041": false
}
"MD041": false,
"MD022": false,
"MD032": false,
"MD007": false,
"MD005": false,
"MD030": false,
"MD031": false,
"MD034": false
}
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repos:
rev: v0.41.0
hooks:
- id: markdownlint
exclude: '^\.github/instructions/.*\.md$'
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
hooks:
Expand All @@ -30,8 +31,9 @@ repos:
hooks:
- id: psscriptanalyzer
name: psscriptanalyzer
entry: pwsh -Command "Invoke-ScriptAnalyzer -Path ."
language: "powershell"
types: ["powershell"]
entry: pwsh -Command "Invoke-ScriptAnalyzer -Path . -Recurse -ExcludeRule PSAvoidUsingWriteHost"
language: system
types: [powershell]
pass_filenames: false
# Exclude the test file itself from analysis for now
exclude: '^tests/unit/PowerShell/system-maintenance.Tests.ps1$'
16 changes: 8 additions & 8 deletions .templates/template.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Version: 1.0
Created: YYYY-MM-DD
Last Modified: YYYY-MM-DD

Prerequisites:
- PowerShell 5.1 or later
- Administrator privileges
Expand All @@ -42,10 +42,10 @@ param(
[Parameter(Mandatory = $true, HelpMessage = "Description of the parameter")]
[ValidateNotNullOrEmpty()]
[string]$ParameterName,

[Parameter(Mandatory = $false)]
[switch]$Quiet,

[Parameter(Mandatory = $false)]
[switch]$WhatIf
)
Expand Down Expand Up @@ -82,15 +82,15 @@ function Write-Error {
# Main script logic
try {
Write-Info "Starting script execution..."

# Validate prerequisites
if ($WhatIf) {
Write-Info "WhatIf mode enabled - no changes will be made"
}

# Main script functionality goes here
Write-Info "Processing parameter: $ParameterName"

# Example of conditional execution
if ($WhatIf) {
Write-Info "Would perform action with parameter: $ParameterName"
Expand All @@ -99,7 +99,7 @@ try {
# Actual execution logic here
Write-Info "Performing action with parameter: $ParameterName"
}

Write-Success "Script completed successfully"
}
catch {
Expand All @@ -110,4 +110,4 @@ catch {
finally {
# Cleanup code here if needed
Write-Info "Cleanup completed"
}
}
44 changes: 22 additions & 22 deletions .templates/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

Usage:
python template.py [options]

Examples:
python template.py --input file.txt --output result.txt
python template.py --verbose --dry-run
Expand Down Expand Up @@ -44,54 +44,54 @@ def setup_logging(verbose: bool = False) -> None:
def validate_input(input_path: Path) -> bool:
"""
Validate input file or directory.

Args:
input_path: Path to validate

Returns:
True if valid, False otherwise
"""
if not input_path.exists():
logging.error(f"Input path does not exist: {input_path}")
return False

# Add specific validation logic here
return True


def process_data(input_path: Path, output_path: Optional[Path] = None, dry_run: bool = False) -> bool:
"""
Main processing function.

Args:
input_path: Input file or directory path
output_path: Output file or directory path
dry_run: If True, don't make actual changes

Returns:
True if successful, False otherwise
"""
try:
logging.info(f"Processing input: {input_path}")

if dry_run:
logging.info("DRY RUN MODE - No changes will be made")

# Validate input
if not validate_input(input_path):
return False

# Main processing logic goes here
# Replace this with your actual functionality
logging.info("Processing data...")

if output_path and not dry_run:
logging.info(f"Writing output to: {output_path}")
# Write output logic here

logging.info("Processing completed successfully")
return True

except Exception as e:
logging.error(f"Error during processing: {e}")
return False
Expand All @@ -109,46 +109,46 @@ def main() -> int:
%(prog)s --input data.txt --dry-run
"""
)

parser.add_argument(
'--input', '-i',
type=Path,
required=True,
help='Input file or directory path'
)

parser.add_argument(
'--output', '-o',
type=Path,
help='Output file or directory path'
)

parser.add_argument(
'--verbose', '-v',
action='store_true',
help='Enable verbose logging'
)

parser.add_argument(
'--dry-run',
action='store_true',
help='Show what would be done without making changes'
)

args = parser.parse_args()

# Set up logging
setup_logging(args.verbose)

logging.info("Starting script execution")

# Process data
success = process_data(
input_path=args.input,
output_path=args.output,
dry_run=args.dry_run
)

if success:
logging.info("Script completed successfully")
return 0
Expand All @@ -158,4 +158,4 @@ def main() -> int:


if __name__ == '__main__':
sys.exit(main())
sys.exit(main())
Loading
Loading