Help us shape the future of Go! Take the 2026 Go Developer Survey

kotlin

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package kotlin provides Kotlin language support for code analysis.

Package kotlin provides Kotlin language support for code analysis.

This package implements the language.Language interface for Kotlin, using tree-sitter for parsing and custom detectors for anti-pattern detection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CoverageRunner

type CoverageRunner struct {
	// contains filtered or unexported fields
}

CoverageRunner executes Kotlin test coverage via Gradle (Kover or JaCoCo) and parses the resulting JaCoCo-format XML reports.

func NewCoverageRunner

func NewCoverageRunner(timeoutSeconds int, statusReporter status.Reporter) *CoverageRunner

NewCoverageRunner creates a new Kotlin coverage runner.

func (*CoverageRunner) RunCoverage

func (r *CoverageRunner) RunCoverage(projectPath string, excludePatterns []string) ([]*coverage.PackageCoverage, error)

RunCoverage runs the Gradle coverage task and parses the reports. excludePatterns is unused: exclusions are governed by the Gradle build itself (mirroring the JS runner, which also ignores them).

When the Gradle run fails but wrote valid reports (e.g. one module's tests failed while others completed), those reports are returned ALONGSIDE a non-nil error, so the caller can use the partial coverage and still surface the failure.

type DependencyAnalyzer

type DependencyAnalyzer struct{}

DependencyAnalyzer analyzes Kotlin package dependencies.

Unlike the Go and JS analyzers it reads no manifest: the set of internal packages is derived from the `package` declarations of the analyzed files themselves, and the unit of analysis is the declared Kotlin package (not the directory).

func NewDependencyAnalyzer

func NewDependencyAnalyzer(projectPath string) (*DependencyAnalyzer, error)

NewDependencyAnalyzer creates a new Kotlin dependency analyzer. The projectPath argument is required by the language.Language interface but unused: internal packages come from the files' own package declarations.

func (*DependencyAnalyzer) Analyze

Analyze categorizes imports for every declared package.

func (*DependencyAnalyzer) DetectCircularDependencies

func (a *DependencyAnalyzer) DetectCircularDependencies(files []*parser.FileMetrics) ([]*dependencies.CircularDependency, error)

DetectCircularDependencies finds circular import chains between declared packages. Only internal (project-declared) targets become graph edges; self-edges are excluded so intra-package imports never report a cycle.

type KotlinDetectorRunner

type KotlinDetectorRunner struct {
	// contains filtered or unexported fields
}

KotlinDetectorRunner implements language.DetectorRunner for Kotlin source code.

func NewDetectorRunner

func NewDetectorRunner(cfg *config.AnalysisConfig) *KotlinDetectorRunner

NewDetectorRunner creates a new detector runner for Kotlin source code.

func (*KotlinDetectorRunner) RunDetectors

RunDetectors parses a Kotlin file and runs all enabled detectors.

type KotlinLanguage

type KotlinLanguage struct{}

KotlinLanguage implements language.Language for Kotlin source code.

func (*KotlinLanguage) CoverageRunner

func (k *KotlinLanguage) CoverageRunner(cfg *config.AnalysisConfig, statusReporter status.Reporter) language.CoverageRunner

CoverageRunner returns a Gradle-based (Kover/JaCoCo) coverage runner.

func (*KotlinLanguage) DefaultExcludePatterns

func (k *KotlinLanguage) DefaultExcludePatterns() []string

DefaultExcludePatterns returns Kotlin/Gradle-specific exclude patterns.

func (*KotlinLanguage) DependencyAnalyzer

func (k *KotlinLanguage) DependencyAnalyzer(projectPath string) (language.DependencyAnalyzer, error)

DependencyAnalyzer returns a Kotlin dependency analyzer grouping by declared package.

func (*KotlinLanguage) DetectorRunner

DetectorRunner returns a Kotlin-specific detector runner.

func (*KotlinLanguage) DisplayName

func (k *KotlinLanguage) DisplayName() string

DisplayName returns "Kotlin".

func (*KotlinLanguage) Extensions

func (k *KotlinLanguage) Extensions() []string

Extensions returns [".kt"]. .kts files (Gradle build scripts) are deliberately excluded: they are build configuration, not production code, and would pollute codebase metrics.

func (*KotlinLanguage) Name

func (k *KotlinLanguage) Name() string

Name returns "kotlin".

func (*KotlinLanguage) Parser

func (k *KotlinLanguage) Parser(workers int) parser.Parser

Parser returns a tree-sitter based Kotlin parser with the specified number of workers.

type KotlinParser

type KotlinParser struct {
	// contains filtered or unexported fields
}

KotlinParser implements parser.Parser for Kotlin source files using tree-sitter.

func NewParser

func NewParser(workers int) *KotlinParser

NewParser creates a new Kotlin parser. The workers parameter controls parallel parsing (0=auto, 1=sequential).

func (*KotlinParser) ParseDirectory

func (p *KotlinParser) ParseDirectory(rootPath string, excludePatterns []string, extensions []string, statusReporter status.Reporter) ([]*parser.FileMetrics, []error)

ParseDirectory recursively parses all Kotlin files in a directory. If Workers is set to 1, parsing is sequential. Otherwise, files are parsed in parallel.

func (*KotlinParser) ParseFile

func (p *KotlinParser) ParseFile(path string) (*parser.FileMetrics, error)

ParseFile parses a single Kotlin file and extracts comprehensive metrics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL