Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b67d1f9
Added new GitHub action, check conventions and guidelines
purriza Feb 6, 2026
88e7e4c
Removed GitHub action to check conventions
purriza Feb 9, 2026
ef1fcfc
test: Add Solidity contract violations for CodeRabbit testing
purriza Feb 9, 2026
afb68fc
refactor: organize CodeRabbit violations by category and add deployme…
purriza Feb 10, 2026
ebf06ab
fix: move deployment script violations to script/deploy/ for CodeRabb…
purriza Feb 10, 2026
a6bc51f
fix: move Solidity violations to src/ for CodeRabbit detection
purriza Feb 10, 2026
e16776c
fix: resolve security warnings in violation examples
purriza Feb 10, 2026
1a20495
feat: add TypeScript violation examples for CodeRabbit validation
purriza Feb 10, 2026
72d67b8
fix: improve TypeScript violation examples for better CodeRabbit dete…
purriza Feb 10, 2026
f4d1c89
fix: update BadCodeQuality and BadImportOrder with improved violations
purriza Feb 10, 2026
bde5903
Merge branch 'main' into SMAR-49-Create-AI-conventions-checker-git-ac…
purriza Feb 10, 2026
21b3949
Removed TypeScript violation examples. Added bash examples
purriza Feb 11, 2026
61729ac
Added Solidity violation file
purriza Feb 11, 2026
f958a82
Removed solidity violation file
purriza Feb 11, 2026
8f34c9a
Added violation test files
purriza Feb 12, 2026
1e74227
Removed scripts
purriza Feb 12, 2026
949c271
Merge branch 'main' into SMAR-49-Create-AI-conventions-checker-git-ac…
purriza Feb 12, 2026
94bd7a8
Added workflow violation file
purriza Feb 12, 2026
5b3b1af
Added .sh violation files
purriza Feb 12, 2026
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
56 changes: 56 additions & 0 deletions script/violations/badCodeQuality.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

# VIOLATION: No usage/help text
# VIOLATION: No environment loading
# VIOLATION: No validation of required variables

NETWORK=$1
CONTRACT=$2

# VIOLATION: Inconsistent indentation
if [[ -z "$NETWORK" ]]; then
echo "Network required"
exit 1
fi

# VIOLATION: Inconsistent naming (camelCase vs snake_case)
contractAddress="0x123"
deployment_name="MyContract"
FACET_LIST=()

# VIOLATION: Unclear exit codes
if [[ -z "$CONTRACT" ]]; then
exit 2 # What does 2 mean?
fi

# VIOLATION: No TODO/FIXME documentation
# TODO fix this later
broken_function() {
echo "This doesn't work"
}

# VIOLATION: Magic numbers without explanation
sleep 5
timeout 120 some_command

# VIOLATION: Overly complex logic without breakdown
result=$(cast call "$CONTRACT" "getData()" | grep "0x" | cut -d' ' -f1 | tr -d '\n' | sed 's/^0x//')

# VIOLATION: No comments for complex regex/awk/sed
echo "$result" | awk '{print $3}' | sed 's/[^0-9]//g'

# VIOLATION: Inconsistent quoting style
echo 'Single quotes'
echo "Double quotes"
echo $UNQUOTED

# VIOLATION: No sourcing of helper functions
# Should source script/helperFunctions.sh and script/playgroundHelpers.sh

# VIOLATION: Not checking command availability
forge build # What if forge is not installed?
jq '.networks' config.json # What if jq is not installed?

# VIOLATION: Hardcoded paths
source /absolute/path/to/config.sh
cat ~/hardcoded/file.txt
81 changes: 81 additions & 0 deletions script/violations/badDRY.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash

# VIOLATION: Duplicate code - should be extracted to function
NETWORK="ethereum"
CONTRACT="0x123"

# First occurrence
if [[ "$NETWORK" == "tron" ]]; then
troncast call "$CONTRACT" "owner()"
else
cast call "$CONTRACT" "owner()"
fi

# Second occurrence - exact duplicate
if [[ "$NETWORK" == "tron" ]]; then
troncast call "$CONTRACT" "owner()"
else
cast call "$CONTRACT" "owner()"
fi

# VIOLATION: Not using existing helpers from helperFunctions.sh
# Reimplementing functionality that already exists
function myOwnCheckFailure() {
if [[ $? -ne 0 ]]; then
echo "Command failed"
exit 1
fi
}

# VIOLATION: Not using universalCast - reimplementing routing
function myCallFunction() {
local network=$1
local contract=$2
local method=$3

if [[ "$network" == "tron" ]]; then
troncast call "$contract" "$method"
else
cast call "$contract" "$method"
fi
}

# VIOLATION: Not sourcing playgroundHelpers.sh and reimplementing logging
function myDebug() {
echo "[DEBUG] $1"
}

function myError() {
echo "[ERROR] $1" >&2
}

# VIOLATION: Duplicate validation logic
address1="0x123"
if [[ "$address1" =~ ^0x[0-9a-fA-F]{40}$ ]]; then
echo "Valid EVM address"
fi

address2="0x456"
if [[ "$address2" =~ ^0x[0-9a-fA-F]{40}$ ]]; then
echo "Valid EVM address"
fi

# VIOLATION: Not checking if getRPCUrl exists before reimplementing
function getMyRpcUrl() {
local network=$1
case "$network" in
ethereum) echo "https://eth.llamarpc.com" ;;
arbitrum) echo "https://arb1.arbitrum.io/rpc" ;;
*) echo "Unknown network" ;;
esac
}

# VIOLATION: Triple duplicate - should extract to function immediately
echo "Deploying to $NETWORK"
forge create Contract --rpc-url "$RPC_URL"

echo "Deploying to $NETWORK"
forge create Contract --rpc-url "$RPC_URL"

echo "Deploying to $NETWORK"
forge create Contract --rpc-url "$RPC_URL"
41 changes: 41 additions & 0 deletions script/violations/badErrorHandling.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# VIOLATION: No checkFailure helper usage
# VIOLATION: No retry logic for RPC-sensitive operations
# VIOLATION: No logging helpers

NETWORK="ethereum"
CONTRACT="0x123"

# VIOLATION: Command that might fail with no error handling
result=$(cast call "$CONTRACT" "owner()")
echo "Owner: $result"

# VIOLATION: No checkFailure after critical operation
cast send "$CONTRACT" "updateOwner(address)" "0xNewOwner" --private-key "$PRIVATE_KEY"

# VIOLATION: Using echo instead of logging helpers
echo "Starting deployment" # Should use echoDebug
echo "ERROR: Failed to deploy" # Should use error()
echo "WARNING: Network slow" # Should use warning()
echo "SUCCESS: Deployed" # Should use success()

# VIOLATION: No retry logic for flaky operations
troncast call "$CONTRACT" "facets()" # Might fail due to rate limits

# VIOLATION: Silent failures with || true
cast call "$CONTRACT" "nonExistentFunction()" || true

# VIOLATION: No error context or actionable messages
if [[ $? -ne 0 ]]; then
echo "Failed"
exit 1
fi

# VIOLATION: Exposing inline secrets in error messages
PRIVATE_KEY="0xabcdef1234567890"
cast send "$CONTRACT" "transfer(address,uint256)" "0x123" "1000" --private-key "$PRIVATE_KEY" || echo "Failed with key: $PRIVATE_KEY"

# VIOLATION: No validation before operations
# Should validate addresses, selectors, etc.
cast call "$CONTRACT" "somethingRandom()"
73 changes: 73 additions & 0 deletions script/violations/badFunctionDocumentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

# VIOLATION: No function documentation at all
function deployContract() {
local network=$1
local contractName=$2

if [[ "$network" == "tron" ]]; then
troncast deploy "$contractName"
else
forge create "$contractName"
fi
}

# VIOLATION: Inconsistent documentation format
# This function does something
# params: network, address
function checkOwner() {
local network=$1
local addr=$2
cast call "$addr" "owner()"
}

# VIOLATION: Missing usage/parameter descriptions
# Function: updateConfig
function updateConfig() {
local NETWORK=$1 # VIOLATION: Parameters should be lowercase in code
local VALUE=$2
echo "Updating config"
}

# VIOLATION: No routing/behavior documentation for universalCast usage
function makeCall() {
universalCast "call" "$1" "$2" "owner()"
}

# VIOLATION: Missing returns documentation
function getOwner() {
local contract=$1
cast call "$contract" "owner()"
}

# VIOLATION: No examples provided
function complexOperation() {
local network=$1
local contract=$2
local selector=$3

# Complex logic with no explanation
if [[ "$network" == "tron" ]]; then
troncast call "$contract" "$selector"
else
cast call "$contract" "$selector"
fi
}

# VIOLATION: Using lowercase parameters in docs but UPPERCASE in code
# Parameters:
# - network: Network name
# - address: Contract address
function badParamStyle() {
local NETWORK=$1 # Inconsistent with docs
local ADDRESS=$2
}

# VIOLATION: Missing "Optional:" prefix for optional parameters
# Parameters:
# - network
# - timeout (optional)
function withOptional() {
local network=$1
local timeout=${2:-30}
}
58 changes: 58 additions & 0 deletions script/violations/badNetworkAbstraction.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# VIOLATION: Hardcoded network checks everywhere (CRITICAL)

NETWORK="tron"
CONTRACT="TXYZabc123"

# VIOLATION: Should use universalCast instead of hardcoded if/else
if [[ "$NETWORK" == "tron" ]]; then
echo "Calling Tron contract"
troncast call "$CONTRACT" "balanceOf(address)" "0x123"
elif [[ "$NETWORK" == "arbitrum" ]]; then
echo "Calling Arbitrum contract"
cast call "$CONTRACT" "balanceOf(address)" "0x123" --rpc-url "$ARB_RPC"
else
echo "Calling EVM contract"
cast call "$CONTRACT" "balanceOf(address)" "0x123"
fi

# VIOLATION: Not using validation helpers
# Should use: isValidTronAddress, isValidEvmAddress, isZeroAddress
address="0x0000000000000000000000000000000000000000"
if [[ "$address" == "0x0000000000000000000000000000000000000000" ]]; then
echo "Zero address"
fi

# VIOLATION: Not using getRPCUrl helper
if [[ "$NETWORK" == "tron" ]]; then
RPC_URL="https://api.trongrid.io"
else
RPC_URL="https://eth-mainnet.alchemyapi.io/v2/YOUR-API-KEY"
fi

# VIOLATION: Not using getPrivateKey helper
if [[ "$NETWORK" == "tron" ]]; then
PRIVATE_KEY="$TRON_PRIVATE_KEY"
else
PRIVATE_KEY="$ETH_PRIVATE_KEY"
fi

# VIOLATION: Should use sendOrPropose for transactions
if [[ "$NETWORK" == "tron" ]]; then
troncast send "$CONTRACT" "transfer(address,uint256)" "$ADDRESS" "1000000000000000000"
else
cast send "$CONTRACT" "transfer(address,uint256)" "$ADDRESS" "1000000000000000000"
fi

# VIOLATION: Not using isTronNetwork helper
if [[ "$NETWORK" == "tron" ]]; then
echo "It's Tron"
fi

# VIOLATION: Not using getTronEnv helper
if [[ "$NETWORK" == "tron" ]]; then
ENV_VAR="TRON_PRIVATE_KEY"
else
ENV_VAR="PRIVATE_KEY"
fi
46 changes: 46 additions & 0 deletions script/violations/badStructure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# VIOLATION: Missing #!/bin/bash shebang

# VIOLATION: No functions, everything inline
# VIOLATION: No DRY principle - duplicated code

# VIOLATION: Variables not in UPPERCASE
network="mainnet"
contractAddress="0x1234"

# VIOLATION: No error handling with checkFailure
# VIOLATION: No logging helpers (echoDebug, error, warning, success)

# VIOLATION: Hardcoded network checks instead of using universalCast
if [[ "$network" == "tron" ]]; then
# VIOLATION: Direct troncast call instead of universalCast
troncast call "$contractAddress" "facets()"
else
# VIOLATION: Direct cast call instead of universalCast
cast call "$contractAddress" "facets()"
fi

# VIOLATION: Duplicate logic (should be in a function)
if [[ "$network" == "tron" ]]; then
troncast call "$contractAddress" "owner()"
else
cast call "$contractAddress" "owner()"
fi

# VIOLATION: Unquoted variable expansion
echo $contractAddress

# VIOLATION: Unsafe variable expansion (should use ${VAR:-})
echo $UNDEFINED_VAR

# VIOLATION: No validation of required variables
# VIOLATION: No environment loading from .env/config.sh

# VIOLATION: Using $VAR[@] instead of ${VAR[@]:-}
FACETS=(Facet1 Facet2)
for facet in ${FACETS[@]}; do
echo $facet
done

# VIOLATION: No exit codes
# VIOLATION: No usage/help text
# VIOLATION: Inconsistent indentation
Loading
Loading