Empty Kotlin File

ID

kotlin.empty_kotlin_file

Severity

info

Remediation Complexity

medium

Remediation Risk

low

Remediation Effort

medium

Resource

Code Smell

Language

Kotlin

Tags

empty, file

Description

Reports .kt files that declare no top-level functions, classes, objects, properties or type aliases. The file may still contain a package header and imports but contributes no code to the project.

Rationale

// FLAW — file with only a package header and imports
package com.example

import java.io.File

// OK — file declares at least one top-level element
package com.example

fun greet() = "hello"

Empty files are usually left over from refactorings — declarations were moved or deleted without removing the surrounding file. They clutter the source tree, dilute grep results and slow incremental builds.

Remediation

  • Delete the file if it is no longer needed.

  • Move pending declarations into the file or merge it with another file in the same package.