You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何查看Sonarwhal测试结果、日志及命令行运行生成的问题?

Got it, let's break down how to handle these two questions about Sonarwhal:

Viewing Sonarwhal Test Results & Logs

Sonarwhal provides multiple ways to access test results and logs, both in real-time and as persistent files. Here's what you can do:

  • Real-time verbose logs in the terminal: By default, Sonarwhal outputs basic execution logs to your command line. For deeper debug-level details (like rule application steps, network requests, or error context), add the --debug flag to your scan command. Example:

    sonarwhal https://example.com --debug
    
  • Export results to persistent files: You can save full scan results to structured formats for later review. Use the --format flag with your preferred output type, then redirect the output to a file. Common options include:

    # Save results as a machine-readable JSON file
    sonarwhal https://example.com --format json > sonarwhal-results.json
    # Generate an interactive HTML report (great for human review)
    sonarwhal https://example.com --format html > sonarwhal-report.html
    

    The HTML report is particularly useful—it lets you click through issues to see context and fix guidance directly in your browser.

Getting Detailed Info on Detected Issues

The default terminal output is concise, but you can expand it to get full context on each problem with these tricks:

  • Use the --verbose flag: Adding this flag to your scan command will print expanded details for every issue in the terminal, including:

    • The exact rule that was violated
    • A detailed explanation of why the issue matters
    • Practical suggestions for fixing it
      Example command:
    sonarwhal https://example.com --verbose
    
  • Inspect exported reports: The JSON or HTML exports include complete details for every detected issue. For JSON, you can use tools like jq to filter and analyze specific issues (e.g., only high-severity problems):

    cat sonarwhal-results.json | jq '.issues[] | select(.severity == "high")'
    

    The HTML report takes it a step further, often showing affected code snippets and step-by-step fix instructions.

  • Explain specific rules directly: If you have a rule ID (like no-inline-styles), you can pull up its full documentation right in the terminal with:

    sonarwhal rule explain <rule-id>
    

    This will give you the rule's purpose, examples of bad/good code, and best practices for resolving violations.

I’ve relied on these methods countless times when debugging Sonarwhal scans, so they should cover what you’re looking for!

内容的提问来源于stack exchange,提问作者David

火山引擎 最新活动