Repository navigation
codescene setup
github-actions[bot] edited this page Oct 6, 2025
·
1 revision
CodeScene CLI has been successfully installed and configured for your project!
- β
CodeScene CLI installed at
~/.local/bin/cs - β
Access token configured (
CS_ACCESS_TOKEN) - β CLI is functional and tested
- β
.codescene-rules.json- Custom rules for different file types - β Stricter rules for source code, relaxed for tests and examples
- β Pre-commit hook added for automatic code health checks
- β
Makefile targets:
-
make codescene- Full analysis -
make codescene-delta- Delta analysis -
make quality-full- All quality checks including CodeScene
-
- β
Analysis script at
scripts/codescene_analysis.sh
- β
GitHub Actions workflow (
.github/workflows/codescene-analysis.yml) - β Automatic PR analysis with comments
- β Delta analysis on pull requests
# Check a single file
cs check src/pyeuropepmc/article.py
# Review with detailed output
cs review src/pyeuropepmc/article.py
# Delta analysis (compare with main branch)
cs delta main
# Check staged changes only
cs delta --staged
# Interactive mode (prompts for fixes)
cs delta --interactive# Run full CodeScene analysis
make codescene
# Run delta analysis only
make codescene-delta
# Run all quality checks (ruff, mypy, bandit, codescene)
make quality-full# Full analysis
./scripts/codescene_analysis.sh
# Delta analysis only
./scripts/codescene_analysis.sh delta
# Help
./scripts/codescene_analysis.sh helpIssues Found:
β οΈ Code duplication in multiple locationsβ οΈ Functions with 5-7 arguments (threshold: 4)β οΈ Complex conditional expressionsβ οΈ Overall code complexity
Issues Found:
β οΈ Complex methods (cyclomatic complexity up to 18!)β οΈ Bumpy road patternsβ οΈ Multiple complex conditionals
-
Break down complex methods (cc > 10)
-
_advanced_search()method (cc=18) needs refactoring - Consider splitting into smaller, focused functions
-
-
Simplify conditional logic
- Extract complex conditions into well-named boolean functions
- Use early returns to reduce nesting
-
Reduce function arguments
- Use data classes or configuration objects
- Group related parameters into dictionaries
-
Eliminate code duplication
- Extract common patterns into utility functions
- Consider using inheritance or composition
- Method length - Keep methods under 20 lines
- Single responsibility - Each function should do one thing
- Descriptive naming - Use clear, intention-revealing names
- Automatically runs on
git commit - Checks all staged Python files
- Prevents commits with severe code health issues
- Automatic analysis on PR creation/updates
- Comments added to PR with findings
- Delta analysis shows impact of changes
# Weekly full analysis
make codescene
# Before each PR
make codescene-deltaEdit .codescene-rules.json to adjust:
- Complexity thresholds
- Argument count limits
- File-specific rules
-
Address high-priority issues in
search.py - Set up regular code health monitoring
- Train team on CodeScene metrics and best practices
- Consider CodeScene enterprise features for more insights
CodeScene CLI is now fully integrated into your development workflow! π