Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问clear审计通过

java-coverageJava coverage 搜索

Agent Skill

用于辅助 Java 项目开发、面向对象设计、Spring 生态、Maven 或 Gradle 依赖和后端工程实践。它适合让 Agent 分析类结构、设计接口、整理服务分层、生成测试或检查常见代码坏味道。使用时需要结合项目已有架构、包结构和依赖版本,不应只按通用教程改代码;涉及数据库、事务、并发或框架配置时,应先确认运行环境和回归测试范围。

总安装

449

周安装

18

GitHub Stars

38

下载量

145
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:java-coverage(Java coverage 搜索)
来源仓库:https://github.com/bitsoex/bitso-java
仓库路径:skills/java-coverage
安装命令:
npx skills add https://github.com/bitsoex/bitso-java --skill java-coverage
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/bitsoex/bitso-java --skill java-coverage

简介

用于辅助 Java 项目开发、面向对象设计和 Spring 生态集成。

  • 适合分析类结构、设计接口、整理服务分层或生成测试代码。
  • 使用时需结合项目已有架构、包结构和依赖版本,避免仅按教程修改代码。
  • 涉及数据库、事务或并发配置时,应先确认运行环境和回归测试范围。
  • java-coverage 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Java Coverage

JaCoCo code coverage configuration for Java/Gradle projects.

When to use this skill

  • Setting up code coverage reporting
  • Configuring coverage thresholds
  • Aggregating coverage across modules
  • Integrating with SonarQube
  • Troubleshooting coverage reports
  • When asked to "improve test coverage"

Skill Contents

Sections

Available Resources

references/ - Detailed documentation


Quick Start

1. Apply JaCoCo Plugin

plugins {
    id 'jacoco'
}

jacoco {
    toolVersion = "0.8.14"
}

2. Configure Report Task

jacocoTestReport {
    dependsOn test

    reports {
        xml.required = true  // For SonarQube
        html.required = true // For local viewing
    }
}

test {
    finalizedBy jacocoTestReport
}

3. Run Coverage

./gradlew test jacocoTestReport
# Report at: build/reports/jacoco/test/html/index.html

Coverage Thresholds

jacocoTestCoverageVerification {
    violationRules {
        rule {
            limit {
                minimum = 0.80  // 80% minimum coverage
            }
        }

        rule {
            element = 'CLASS'
            excludes = ['*.generated.*', '*.config.*']
            limit {
                counter = 'LINE'
                minimum = 0.70
            }
        }
    }
}

check.dependsOn jacocoTestCoverageVerification

Exclusions

Common patterns to exclude from coverage:

jacocoTestReport {
    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect {
            fileTree(dir: it, exclude: [
                '**/generated/**',
                '**/config/**',
                '**/*Config.class',
                '**/*Properties.class',
                '**/Application.class'
            ])
        }))
    }
}

Multi-Module Aggregation

For aggregated reports across modules, use the modern jacoco-report-aggregation plugin (Gradle 7.4+):

// In root build.gradle
plugins {
    id 'base'
    id 'jacoco-report-aggregation'
}

// Ensure subprojects are evaluated first
subprojects.each { evaluationDependsOn(it.path) }

dependencies {
    subprojects.each { jacocoAggregation it }
}

reporting {
    reports {
        testCodeCoverageReport(JacocoCoverageReport) {
            testType = TestSuiteType.UNIT_TEST
        }
    }
}

For older Gradle versions, use a manual task with defensive filtering:

// In root build.gradle (Gradle < 7.4)
task jacocoRootReport(type: JacocoReport) {
    dependsOn subprojects*.test

    // Use defensive filtering to avoid missing-directory errors
    def srcDirs = files(subprojects*.sourceSets*.main*.allSource*.srcDirs).filter { it.exists() }
    def classDirs = files(subprojects*.sourceSets*.main*.output).filter { it.exists() }
    def execData = files(subprojects*.jacocoTestReport*.executionData).filter { it.exists() }

    additionalSourceDirs.from(srcDirs)
    sourceDirectories.from(srcDirs)
    classDirectories.from(classDirs)
    executionData.from(execData)

    reports {
        xml.required = true
        html.required = true
    }
}

SonarQube Integration

sonar {
    properties {
        property 'sonar.coverage.jacoco.xmlReportPaths',
            "${projectDir}/build/reports/jacoco/test/jacocoTestReport.xml"
    }
}

Checking Coverage via SonarQube MCP

Instead of running local JaCoCo builds to check current coverage state, use SonarQube MCP tools for faster feedback:

ToolPurpose
search_files_by_coverageFind files with lowest coverage
get_file_coverage_detailsLine-by-line coverage for a specific file
get_component_measuresProject/module-level coverage metric
get_project_quality_gate_statusCheck if coverage gate passes
# Find low-coverage files
search_files_by_coverage: projectKey: "my-service"

# Check specific file coverage
get_file_coverage_details: key: "my-service:src/main/java/com/bitso/Service.java"

# Check overall coverage
get_component_measures: component: "my-service", metricKeys: ["coverage"]

MCP reflects the last CI analysis. Use JaCoCo locally to generate new coverage after writing tests.

See fix-sonarqube coverage reference for the full MCP coverage workflow.

References

ReferenceDescription
references/exclusion-patterns.mdCommon exclusion patterns
references/multi-module.mdMulti-module aggregation

Related Rules

Related Skills

SkillPurpose
java-testingTest configuration
fix-sonarqubeSonarQube setup
gradle-standardsGradle configuration

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.35%
按下载量换算43

OpenCode

23.59%
按下载量换算34

Antigravity

19.23%
按下载量换算28

windsurf

13.3%
按下载量换算19

Codex

7.8%
按下载量换算11

Gemini CLI

3.14%
按下载量换算5

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills