-
Notifications
You must be signed in to change notification settings - Fork 0
π¨ Palette: κΈ΄ λλ ν 리 μ΄λ¦μ λͺ¨λ°μΌ λ μ΄μμ κΉ¨μ§ λ°©μ§ #374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
6d7b7ee
2e82235
0e5b49f
4062c2c
0b04630
a705557
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,9 @@ main { | |
| max-width: 800px; | ||
| margin: 0 auto; | ||
| } | ||
| h1 { | ||
| overflow-wrap: anywhere; | ||
| } | ||
| ul { | ||
| list-style-type: none; | ||
| padding-left: 0; | ||
|
|
@@ -144,20 +147,14 @@ internal fun crawl_directories( | |
| processDirectory: (File, Set<String>, Array<File>?) -> Unit = { file, exclude, files -> process_dir(file, exclude, files) }, | ||
| processIgnoreFile: (File, Array<String>?) -> Set<String> = { file, names -> process_ignore_file(file, names) }, | ||
| listFiles: (File) -> Array<File>? = { it.listFiles() }, | ||
| readAttributes: (File) -> BasicFileAttributes? = { | ||
| try { | ||
| Files.readAttributes(it.toPath(), BasicFileAttributes::class.java, LinkOption.NOFOLLOW_LINKS) | ||
| } catch (e: Exception) { | ||
| null | ||
| } | ||
| }, | ||
| isDirectory: (File) -> Boolean = { Files.isDirectory(it.toPath(), LinkOption.NOFOLLOW_LINKS) }, | ||
| isSymbolicLink: (File) -> Boolean = { Files.isSymbolicLink(it.toPath()) }, | ||
| readIdentity: (File) -> FileIdentity = ::read_file_identity | ||
| ) { | ||
| var lle: LinkedListEntry? = ll.pull() | ||
|
|
||
| while(lle != null){ | ||
| val attrs = readAttributes(lle.file) | ||
| if (attrs == null || !attrs.isDirectory) { | ||
| if (!isDirectory(lle.file)) { | ||
| lle = ll.pull() | ||
| continue | ||
| } | ||
|
|
@@ -180,28 +177,18 @@ internal fun crawl_directories( | |
|
|
||
| if(maxLevel == -1 || currentLevel < maxLevel) { | ||
| dirFiles?.forEach { | ||
| // β‘ Bolt Performance Optimization: Short-circuit OS stat calls | ||
| // β‘ Bolt Performance Optimization: Short-circuit OS stat calls (isDirectory/isSymbolicLink) | ||
| // by checking cheap in-memory string exclusion rules first | ||
| if(!it.name.isHiddenFile() && it.name !in exclude) { | ||
| val childAttrs = readAttributes(it) | ||
| if(childAttrs != null && childAttrs.isDirectory && !childAttrs.isSymbolicLink) { | ||
| val childEntry = LinkedListEntry(it, currentLevel+1, readIdentity(it).key) | ||
| ll.push(childEntry) | ||
| } | ||
| if(!it.name.startsWith(".") && it.name !in exclude && isDirectory(it) && !isSymbolicLink(it)) { | ||
| val childEntry = LinkedListEntry(it, currentLevel+1, readIdentity(it).key) | ||
| ll.push(childEntry) | ||
|
Comment on lines
+180
to
+184
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π Maintainability & Code Quality | π‘ Minor | β‘ Quick win π§© Analysis chainπ Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 4 'isSymbolicLink\s*=\s*\{|crawl_directories' src/test/kotlinRepository: ContextualWisdomLab/html4tree Length of output: 6710 π Script executed: #!/bin/bash
set -euo pipefail
echo "== candidate files =="
fd -a 'src/main/kotlin/html4tree/main.kt|src/test/kotlin/html4tree/MainTest.kt' . | sed 's#^\./##'
echo "== main.kt relevant section =="
sed -n '150,205p' src/main/kotlin/html4tree/main.kt | cat -n
echo "== MainTest crawl_directories occurrences with context =="
sed -n '130,210p;225,250p;680,710p' src/test/kotlin/html4tree/MainTest.kt | cat -n
echo "== all isSymbolicLink occurrences =="
rg -n -C 3 'isSymbolicLink' src/test/kotlin src/main/kotlin
echo "== static branch coverage probe for crawl_directories condition ==
python3 - <<'PY'
from pathlib import Path
test = Path('src/test/kotlin/html4tree/MainTest.kt').read_text()
main = Path('src/main/kotlin/html4tree/main.kt').read_text()
print('contains isSymbolicLink == false assignments:', 'isSymbolicLink = { false }' in test)
print('contains isSymbolicLink == true assignment:', 'isSymbolicLink = { true }' in test)
print('crawl_directories call count around isSymbolicLink:', test.count('crawl_directories'))
print('branch expression in main:', 'if!' in main and 'isDirectory(it) && !isSymbolicLink(it)' in main)
PYRepository: ContextualWisdomLab/html4tree Length of output: 16195 μ¬λ³Όλ¦ λ§ν¬ μ°¨λ¨ λΆκΈ°λ₯Ό ν μ€νΈνμΈμ.
π€ Prompt for AI AgentsSource: Coding guidelines |
||
| } | ||
| } | ||
| } | ||
| lle = ll.pull() | ||
| } | ||
| } | ||
|
|
||
| fun String.isHiddenFile(): Boolean { | ||
| return when (firstOrNull()) { | ||
| '.', '\u3002', '\uFF0E', '\uFF61' -> true | ||
| else -> false | ||
| } | ||
| } | ||
|
|
||
| // β‘ Bolt Performance Optimization: Single-pass loop with lazy StringBuilder | ||
| // Chained `.replace()` calls allocate multiple intermediate strings. | ||
| // A single pass over the string lazily allocating a StringBuilder is much faster. | ||
|
|
@@ -317,9 +304,9 @@ fun process_ignore_file(curr_dir: File, dirFilesNames: Array<String>? = null): S | |
| val defaultSensitiveFiles = listOf(".git", ".env", ".ssh", ".htpasswd", ".htaccess", "id_rsa", "id_ed25519", "secrets.yml", ".html4ignore", ".DS_Store", ".aws", ".kube", ".npmrc", ".gnupg", "config.json", "credentials.json") | ||
| files_to_exclude.addAll(defaultSensitiveFiles) | ||
|
|
||
| // 보μ ν₯μ: dot-like prefixes are treated as hidden to prevent visually-confusable sensitive entries from reaching generated indexes. | ||
| // 보μ ν₯μ: .env, .git λ± λ―Όκ°ν μ λ³΄κ° ν¬ν¨λ μ μλ μ¨κΉ νμΌ(.μΌλ‘ μμνλ λͺ¨λ νλͺ©)μ κΈ°λ³Έμ μΌλ‘ λ ΈμΆνμ§ μλλ‘ μ μΈ (μ 보 λ ΈμΆ λ°©μ§) | ||
| (dirFilesNames ?: curr_dir.list())?.forEach { | ||
| if (it.isHiddenFile()) { | ||
| if (it.startsWith(".")) { | ||
| files_to_exclude.add(it) | ||
| } | ||
| } | ||
|
|
@@ -373,7 +360,7 @@ fun process_dir(curr_dir: File, excludeSet: Set<String>? = null, dirFiles: Array | |
| val fileName = it.getName() | ||
| // β‘ Bolt Performance Optimization: Short-circuit string match before expensive OS filesystem calls | ||
| // π‘οΈ Sentinel: Ignore hidden files/directories to prevent sensitive data exposure | ||
| if (!fileName.isHiddenFile() && fileName !in exclude) { | ||
| if (!fileName.startsWith(".") && fileName !in exclude) { | ||
| var isLinkedDirectory = false | ||
| var isSymbolicLink = false | ||
| try { | ||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Security & Privacy | π Major | β‘ Quick win
μ¬λ³Όλ¦ λ§ν¬ νλ³ κ²½λ‘λ₯Ό μ κ·ννμΈμ.
NOFOLLOW_LINKSμ¬μ©μ μ¬λ°λ¦ λλ€. κ·Έλ¬λ λ μ½λ°±μ΄it.toPath()λ₯Ό μ§μ μ¬μ©ν©λλ€. μλ κ²½λ‘μ..κ° ν¬ν¨λ κ²½λ‘μμλ λμΌν νλ³ κ·μΉμ μ μ©νλ €λ©΄it.absoluteFile.toPath().normalize()λ₯Ό μ¬μ©ν΄μΌ ν©λλ€.μμ μμ
As per coding guidelines: μ¬λ³Όλ¦ λ§ν¬ μνκ° μ€μν λ
absoluteFile.toPath().normalize()λ₯Ό μ¬μ©ν΄μΌ ν©λλ€.π Committable suggestion
π€ Prompt for AI Agents
Source: Coding guidelines