Skip to content

Commit 355e99e

Browse files
committed
refactor: remove unused code and imports for Go Report Card A+
- Removed unused helper functions from cmd/promptext/main.go - Removed unused helper functions from pkg/promptext/ - Cleaned up unused imports across the codebase - Fixed staticcheck U1000 (unused) and SA4006 (unused value) warnings All tests passing, staticcheck clean, ready for v0.7.1 release.
1 parent b077d02 commit 355e99e

File tree

8 files changed

+14
-187
lines changed

8 files changed

+14
-187
lines changed

cmd/promptext/main.go

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"path/filepath"
99
"strings"
1010

11-
"github.com/1broseidon/promptext/internal/format"
1211
"github.com/1broseidon/promptext/internal/initializer"
1312
"github.com/1broseidon/promptext/internal/processor"
1413
"github.com/1broseidon/promptext/internal/update"
@@ -398,127 +397,6 @@ func formatTokenCount(tokens int) string {
398397
return result.String()
399398
}
400399

401-
// Helper functions to convert between library and internal types
402-
func parseExtensions(extension string) []string {
403-
if extension == "" {
404-
return nil
405-
}
406-
return strings.Split(extension, ",")
407-
}
408-
409-
func parseExcludes(exclude string) []string {
410-
if exclude == "" {
411-
return nil
412-
}
413-
return strings.Split(exclude, ",")
414-
}
415-
416-
func toInternalProjectOutput(output *promptext.ProjectOutput) *format.ProjectOutput {
417-
if output == nil {
418-
return nil
419-
}
420-
421-
internal := &format.ProjectOutput{}
422-
423-
// Convert DirectoryTree
424-
if output.DirectoryTree != nil {
425-
internal.DirectoryTree = toInternalDirectoryNode(output.DirectoryTree)
426-
}
427-
428-
// Convert GitInfo
429-
if output.GitInfo != nil {
430-
internal.GitInfo = &format.GitInfo{
431-
Branch: output.GitInfo.Branch,
432-
CommitHash: output.GitInfo.CommitHash,
433-
CommitMessage: output.GitInfo.CommitMessage,
434-
}
435-
}
436-
437-
// Convert Metadata
438-
if output.Metadata != nil {
439-
internal.Metadata = &format.Metadata{
440-
Language: output.Metadata.Language,
441-
Version: output.Metadata.Version,
442-
Dependencies: output.Metadata.Dependencies,
443-
}
444-
}
445-
446-
// Convert Files
447-
internal.Files = make([]format.FileInfo, len(output.Files))
448-
for i, file := range output.Files {
449-
internal.Files[i] = format.FileInfo{
450-
Path: file.Path,
451-
Content: file.Content,
452-
Tokens: file.Tokens,
453-
}
454-
if file.Truncation != nil {
455-
internal.Files[i].Truncation = &format.TruncationInfo{
456-
Mode: file.Truncation.Mode,
457-
OriginalTokens: file.Truncation.OriginalTokens,
458-
}
459-
}
460-
}
461-
462-
// Convert FileStats
463-
if output.FileStats != nil {
464-
internal.FileStats = &format.FileStatistics{
465-
TotalFiles: output.FileStats.TotalFiles,
466-
TotalLines: output.FileStats.TotalLines,
467-
PackageCount: output.FileStats.PackageCount,
468-
}
469-
}
470-
471-
// Convert Budget
472-
if output.Budget != nil {
473-
internal.Budget = &format.BudgetInfo{
474-
MaxTokens: output.Budget.MaxTokens,
475-
EstimatedTokens: output.Budget.EstimatedTokens,
476-
FileTruncations: output.Budget.FileTruncations,
477-
}
478-
}
479-
480-
// Convert FilterConfig
481-
if output.FilterConfig != nil {
482-
internal.FilterConfig = &format.FilterConfig{
483-
Includes: output.FilterConfig.Includes,
484-
Excludes: output.FilterConfig.Excludes,
485-
}
486-
}
487-
488-
return internal
489-
}
490-
491-
func toInternalDirectoryNode(node *promptext.DirectoryNode) *format.DirectoryNode {
492-
if node == nil {
493-
return nil
494-
}
495-
496-
internal := &format.DirectoryNode{
497-
Name: node.Name,
498-
Type: node.Type,
499-
}
500-
501-
if len(node.Children) > 0 {
502-
internal.Children = make([]*format.DirectoryNode, len(node.Children))
503-
for i, child := range node.Children {
504-
internal.Children[i] = toInternalDirectoryNode(child)
505-
}
506-
}
507-
508-
return internal
509-
}
510-
511-
func toInternalExcludedList(list []promptext.ExcludedFileInfo) []processor.ExcludedFileInfo {
512-
result := make([]processor.ExcludedFileInfo, len(list))
513-
for i, item := range list {
514-
result[i] = processor.ExcludedFileInfo{
515-
Path: item.Path,
516-
Tokens: item.Tokens,
517-
}
518-
}
519-
return result
520-
}
521-
522400
type cliDeps struct {
523401
stdout io.Writer
524402
stderr io.Writer

examples/token-budget/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ func main() {
114114
fmt.Println("---")
115115

116116
limits := map[string]int{
117-
"GPT-3.5 (4k context)": 2000, // Leave room for response
118-
"GPT-4 (8k context)": 6000,
119-
"Claude (100k context)": 80000,
120-
"GPT-4-Turbo (128k)": 100000,
117+
"GPT-3.5 (4k context)": 2000, // Leave room for response
118+
"GPT-4 (8k context)": 6000,
119+
"Claude (100k context)": 80000,
120+
"GPT-4-Turbo (128k)": 100000,
121121
}
122122

123123
for model, limit := range limits {

internal/initializer/initializer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func TestInitializer_SecurityInputValidation(t *testing.T) {
416416

417417
// Test that non-absolute paths are handled correctly
418418
init = NewInitializer(".", false, true)
419-
err = init.RunQuick()
419+
_ = init.RunQuick()
420420
// Should not panic, may succeed or fail depending on CWD
421421
// Just verify it doesn't panic
422422
}

internal/initializer/templates_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestTemplateGenerator_Generate(t *testing.T) {
6565
name: "Empty project types",
6666
projectTypes: []ProjectType{},
6767
includeTests: false,
68-
expectExts: []string{}, // No extensions added for unknown project
68+
expectExts: []string{}, // No extensions added for unknown project
6969
expectExc: []string{".git", ".svn"}, // Only base excludes
7070
},
7171
}

internal/update/update_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import (
1010
"errors"
1111
"fmt"
1212
"io"
13-
"net"
1413
"net/http"
15-
"net/http/httptest"
1614
"os"
1715
"path/filepath"
1816
"runtime"
@@ -92,19 +90,6 @@ func (f roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) {
9290
return f(req)
9391
}
9492

95-
func newTestServer(t *testing.T, handler http.Handler) *httptest.Server {
96-
t.Helper()
97-
ln, err := net.Listen("tcp4", "127.0.0.1:0")
98-
if err != nil {
99-
t.Fatalf("listen: %v", err)
100-
}
101-
server := httptest.NewUnstartedServer(handler)
102-
server.Listener = ln
103-
server.Start()
104-
t.Cleanup(server.Close)
105-
return server
106-
}
107-
10893
func TestFindReleaseAssets(t *testing.T) {
10994
release := &ReleaseInfo{
11095
Assets: []struct {

pkg/promptext/options.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ type config struct {
2020
// newDefaultConfig creates a config with sensible defaults.
2121
func newDefaultConfig() *config {
2222
return &config{
23-
extensions: nil, // nil means all supported extensions
24-
excludes: nil, // nil means no custom excludes
25-
gitignore: true, // respect .gitignore by default
26-
useDefaultRules: true, // use built-in filtering rules by default
27-
tokenBudget: 0, // 0 means unlimited
28-
format: FormatPTX, // PTX is the default format
29-
verbose: false, // quiet by default
30-
debug: false, // no debug logging by default
23+
extensions: nil, // nil means all supported extensions
24+
excludes: nil, // nil means no custom excludes
25+
gitignore: true, // respect .gitignore by default
26+
useDefaultRules: true, // use built-in filtering rules by default
27+
tokenBudget: 0, // 0 means unlimited
28+
format: FormatPTX, // PTX is the default format
29+
verbose: false, // quiet by default
30+
debug: false, // no debug logging by default
3131
}
3232
}
3333

pkg/promptext/promptext.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"os"
66
"path/filepath"
7-
"strings"
87

98
"github.com/1broseidon/promptext/internal/filter"
109
"github.com/1broseidon/promptext/internal/log"
@@ -250,13 +249,3 @@ func validateDirectory(path string) error {
250249

251250
return nil
252251
}
253-
254-
// Helper function to join extensions for internal use
255-
func joinExtensions(extensions []string) string {
256-
return strings.Join(extensions, ",")
257-
}
258-
259-
// Helper function to join excludes for internal use
260-
func joinExcludes(excludes []string) string {
261-
return strings.Join(excludes, ",")
262-
}

pkg/promptext/result.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package promptext
22

33
import (
44
"github.com/1broseidon/promptext/internal/format"
5-
"github.com/1broseidon/promptext/internal/info"
65
"github.com/1broseidon/promptext/internal/processor"
76
)
87

@@ -252,27 +251,3 @@ func fromInternalDirectoryNode(internal *format.DirectoryNode) *DirectoryNode {
252251

253252
return node
254253
}
255-
256-
// fromInternalProjectInfo converts internal info.ProjectInfo to public types (used internally)
257-
func fromInternalProjectInfo(internal *info.ProjectInfo) (*GitInfo, *Metadata) {
258-
var gitInfo *GitInfo
259-
var metadata *Metadata
260-
261-
if internal.GitInfo != nil {
262-
gitInfo = &GitInfo{
263-
Branch: internal.GitInfo.Branch,
264-
CommitHash: internal.GitInfo.CommitHash,
265-
CommitMessage: internal.GitInfo.CommitMessage,
266-
}
267-
}
268-
269-
if internal.Metadata != nil {
270-
metadata = &Metadata{
271-
Language: internal.Metadata.Language,
272-
Version: internal.Metadata.Version,
273-
Dependencies: internal.Metadata.Dependencies,
274-
}
275-
}
276-
277-
return gitInfo, metadata
278-
}

0 commit comments

Comments
 (0)