Skip to main content

sonar_project_discovery

Analyze a directory to discover project type, languages, frameworks, and recommend configuration.

Description

Automatically detects project characteristics including programming languages, frameworks, build systems, and testing tools. Provides tailored SonarQube configuration recommendations based on discovered features.

Parameters

ParameterTypeRequiredDefaultDescription
pathstringNoCurrent directoryDirectory to analyze
deepbooleanNofalseInclude dependency scanning

Usage

Basic Discovery

What kind of project is this?

Tool call:

{}

Deep Analysis

Analyze this project deeply including dependencies

Tool call:

{
"deep": true
}

Specific Directory

Analyze the backend folder

Tool call:

{
"path": "/Users/dev/myproject/backend",
"deep": true
}

Response Format

PROJECT DISCOVERY REPORT
━━━━━━━━━━━━━━━━━━━━━━━━

📁 Path: /Users/dev/my-awesome-app
📊 Analysis Type: Deep

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔤 LANGUAGES DETECTED:

Primary:
├── TypeScript (68%)
├── JavaScript (22%)
└── CSS (10%)

Configuration:
├── JSON
├── YAML
└── Markdown

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🏗️ PROJECT TYPE: Web Application (Frontend)

Framework: React 18.2.0
Build Tool: Vite 5.0.0
Package Manager: npm

Additional:
├── TypeScript 5.3.0
├── ESLint 8.55.0
├── Prettier 3.1.0
└── Jest 29.7.0

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🧪 TESTING:

Framework: Jest
Coverage: Istanbul
Report Path: coverage/lcov.info (detected)

Test Files:
├── **/*.test.ts
├── **/*.test.tsx
└── **/*.spec.ts

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📂 STRUCTURE:

src/ → Source code (TypeScript/React)
tests/ → Test files
public/ → Static assets
dist/ → Build output (excluded)
node_modules/ → Dependencies (excluded)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚙️ RECOMMENDED CONFIGURATION:

Quality Gate: balanced

Sources: src
Tests: tests,**/*.test.ts,**/*.test.tsx
Exclusions: node_modules/**,dist/**,coverage/**

Coverage Report: coverage/lcov.info

Additional Properties:
├── sonar.typescript.tsconfigPath=tsconfig.json
└── sonar.javascript.lcov.reportPaths=coverage/lcov.info

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📋 NEXT STEPS:

1. Run: sonar_auto_setup (recommended)
Uses detected configuration automatically

2. Or run: sonar_scan_project with autoSetup: true
Sets up and scans in one step

3. For custom config: sonar_generate_config
Create sonar-project.properties manually

Deep Analysis Features

When deep: true:

FeatureDescription
Dependency scanAnalyzes package.json, requirements.txt, etc.
Framework versionExact versions detected
Security checkKnown vulnerable dependencies
Config filesAll config files analyzed
Git infoBranch, remote, ignore patterns

Detection Capabilities

Languages

LanguageDetection Method
TypeScripttsconfig.json, .ts files
JavaScriptpackage.json, .js files
Pythonrequirements.txt, setup.py, .py files
Javapom.xml, build.gradle, .java files
Gogo.mod, .go files
RustCargo.toml, .rs files
C#.csproj, .cs files

Frameworks

FrameworkDetection
Reactreact in package.json
Vuevue in package.json
Angular@angular/core in package.json
Next.jsnext in package.json
Expressexpress in package.json
Djangodjango in requirements.txt
Springspring-boot in pom.xml

Build Tools

ToolDetection
npmpackage-lock.json
yarnyarn.lock
pnpmpnpm-lock.yaml
Mavenpom.xml
Gradlebuild.gradle
piprequirements.txt

Examples

Example 1: New Project Setup

Prompt:

I just cloned this repo, what kind of project is it?

Tool Call:

{
"deep": true
}

Example 2: Monorepo Analysis

Prompt:

Analyze the packages/api folder

Tool Call:

{
"path": "/Users/dev/monorepo/packages/api",
"deep": true
}

Example 3: Quick Check

Prompt:

What languages are used here?

Tool Call:

{}

Best Practices

  1. Run before first scan - Understand project structure
  2. Use deep for full picture - Especially for new projects
  3. Review recommendations - May need adjustment
  4. Re-run after changes - When adding frameworks/tools

Common Issues

"No project detected"

Cause: Directory has no recognizable project files.

Solution: Ensure you're in the correct directory.

"Incomplete detection"

Cause: Unusual project structure.

Solution: Use deep analysis or configure manually.