@@ -26,7 +26,7 @@ data class CodeAnalyzer(
2626) {
2727 companion object {
2828 private const val DEFAULT_MAX_LINES = 100
29- private const val SUMMARY_MAX_LINES = 500
29+ private const val SUMMARY_MAX_LINES = 250
3030 private const val DEFAULT_BINARY_SIZE_THRESHOLD = 1024 * 1024L // 1MB
3131 private const val DEFAULT_BINARY_DETECTION_THRESHOLD = 0.05
3232
@@ -215,7 +215,7 @@ data class CodeAnalyzer(
215215 " kotlin" to
216216 LanguagePatterns (
217217 Regex (
218- " class|interface|object|enum class|data class|sealed class|fun|val|var|const|typealias|annotation class"
218+ " \\ b( class|interface|object|enum\\ s+ class|data\\ s+ class|sealed\\ s+ class|fun|val|var|const|typealias|annotation\\ s+ class|import|package) \\ b "
219219 ),
220220 listOf (" //" ),
221221 " /*" ,
@@ -224,7 +224,7 @@ data class CodeAnalyzer(
224224 " scala" to
225225 LanguagePatterns (
226226 Regex (
227- " class|object|trait|case class|case object|def|val|var|lazy val|type|implicit|sealed|abstract|override|package object"
227+ " \\ b( class|object|trait|case\\ s+ class|case\\ s+ object|def|val|var|lazy\\ s+ val|type|implicit|sealed|abstract|override|package\\ s+ object|import|package) \\ b "
228228 ),
229229 listOf (" //" ),
230230 " /*" ,
@@ -233,49 +233,71 @@ data class CodeAnalyzer(
233233 " java" to
234234 LanguagePatterns (
235235 Regex (
236- " class|interface|enum|@interface|record|public|private|protected|static|abstract|final|synchronized|volatile|native|transient|strictfp|void"
236+ " \\ b( class|interface|enum|@interface|record|public|private|protected|static|abstract|final|synchronized|volatile|native|transient|strictfp|void|import|package) \\ b "
237237 ),
238238 listOf (" //" ),
239239 " /*" ,
240240 " */" ,
241241 ),
242- " python" to LanguagePatterns (Regex (" def|class|async def|@\\ w+|import|from" ), listOf (" #" ), " \"\"\" " , " \"\"\" " ),
242+ " python" to
243+ LanguagePatterns (
244+ Regex (" \\ b(def|class|async\\ s+def)\\ b|@\\ w+|\\ b(import|from)\\ b" ),
245+ listOf (" #" ),
246+ " \"\"\" " ,
247+ " \"\"\" " ,
248+ ),
243249 " ruby" to
244- LanguagePatterns (Regex (" def|class|module|attr_\\ w+|require|include|extend" ), listOf (" #" ), " =begin" , " =end" ),
250+ LanguagePatterns (
251+ Regex (" \\ b(def|class|module|attr_\\ w+|require|include|extend)\\ b" ),
252+ listOf (" #" ),
253+ " =begin" ,
254+ " =end" ,
255+ ),
245256 " javascript" to
246257 LanguagePatterns (
247- Regex (" function|class|const|let|var|import|export|interface|type|enum|namespace" ),
258+ Regex (" \\ b( function|class|const|let|var|import|export|interface|type|enum|namespace) \\ b " ),
248259 listOf (" //" ),
249260 " /*" ,
250261 " */" ,
251262 ),
252263 " typescript" to
253264 LanguagePatterns (
254- Regex (" function|class|const|let|var|import|export|interface|type|enum|namespace" ),
265+ Regex (" \\ b(function|class|const|let|var|import|export|interface|type|enum|namespace)\\ b" ),
266+ listOf (" //" ),
267+ " /*" ,
268+ " */" ,
269+ ),
270+ " go" to
271+ LanguagePatterns (
272+ Regex (" \\ b(func|type|struct|interface|package|import|var|const)\\ b" ),
255273 listOf (" //" ),
256274 " /*" ,
257275 " */" ,
258276 ),
259- " go" to LanguagePatterns (Regex (" func|type|struct|interface|package|import|var|const" ), listOf (" //" ), " /*" , " */" ),
260277 " rust" to
261278 LanguagePatterns (
262- Regex (" fn|struct|enum|trait|impl|pub|use|mod|const|static|type|async|unsafe" ),
279+ Regex (" \\ b( fn|struct|enum|trait|impl|pub|use|mod|const|static|type|async|unsafe) \\ b " ),
263280 listOf (" //" ),
264281 " /*" ,
265282 " */" ,
266283 ),
267284 " c" to
268- LanguagePatterns (Regex (" struct|enum|typedef|void|int|char|bool|extern|static|class" ), listOf (" //" ), " /*" , " */" ),
285+ LanguagePatterns (
286+ Regex (" \\ b(struct|enum|typedef|void|int|char|bool|extern|static|class)\\ b" ),
287+ listOf (" //" ),
288+ " /*" ,
289+ " */" ,
290+ ),
269291 " cpp" to
270292 LanguagePatterns (
271- Regex (" class|struct|enum|typedef|namespace|template|void|int|char|bool|auto|extern|static|virtual" ),
293+ Regex (" \\ b( class|struct|enum|typedef|namespace|template|void|int|char|bool|auto|extern|static|virtual) \\ b " ),
272294 listOf (" //" ),
273295 " /*" ,
274296 " */" ,
275297 ),
276298 " default" to
277299 LanguagePatterns (
278- Regex (" class|interface|object|enum|fun|def|function|public|private|protected|static" ),
300+ Regex (" \\ b( class|interface|object|enum|fun|def|function|public|private|protected|static) \\ b " ),
279301 listOf (" //" , " #" ),
280302 " /*" ,
281303 " */" ,
0 commit comments