• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jesperancinha / markdowner / #194

pending completion
#194

push

github-ci

web-flow
Merge pull request #149 from jesperancinha/migration-to-kotlin

Migration to kotlin

333 of 333 new or added lines in 13 files covered. (100.0%)

274 of 333 relevant lines covered (82.28%)

8.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/markdowner-filter/src/main/kotlin/org/jesperancinha/parser/markdowner/filter/NPMFilter.kt
1
package org.jesperancinha.parser.markdowner.filter
2

3
import com.google.gson.Gson
4
import com.google.gson.JsonElement
5
import org.slf4j.LoggerFactory
6
import java.io.FileReader
7
import java.nio.file.Path
8
import java.util.*
9

10
/**
11
 * Filter to check if folder contains a Node Package Manager project and keeps the project name in memory
12
 */
13
class NPMFilter : ProjectFilter<Path>() {
6✔
14
    override fun test(path: Path): Boolean {
15
        val maybeNPMBuild = path.fileName.toString() == PACKAGE_JSON
12✔
16
        try {
2✔
17
            if (maybeNPMBuild) {
4✔
18
                val jsonElement = Gson().getAdapter(JsonElement::class.java).fromJson(FileReader(path.toFile()))
28✔
19
                val name = jsonElement.asJsonObject[NAME]
10✔
20
                if (Objects.nonNull(name)) {
6✔
21
                    lastProjectName = name.asString
8✔
22
                    return true
4✔
23
                }
24
            }
25
        } catch (e: Exception) {
×
26
            logger.trace("Not a valid JSON!", e)
×
27
        }
28
        return false
4✔
29
    }
30

31
    override fun lastProjectName(): String? {
32
        return lastProjectName
6✔
33
    }
34

35
    companion object {
36
        private val NAME: String = "name"
4✔
37
        private val PACKAGE_JSON: String = "package.json"
4✔
38
        private val logger = LoggerFactory.getLogger(NPMFilter::class.java)
8✔
39
    }
40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc