Skip to content

Commit 16ca831

Browse files
authored
CHORE: 0.1.0 pre-release (#1)
1. use dfs for going around file tree 2. add statistics columns: LOC & Files 3. save statistics in struct StatisticsResponse
1 parent a284b05 commit 16ca831

26 files changed

Lines changed: 514 additions & 15 deletions

.github/workflows/check.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: check
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- dev/*
9+
10+
jobs:
11+
test:
12+
name: test-${{ matrix.os }}-go${{ matrix.go-version }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
go-version:
17+
- "1.25"
18+
- "1.24"
19+
os:
20+
- "ubuntu-latest"
21+
- "windows-latest"
22+
- "macos-latest"
23+
24+
steps:
25+
- name: checkout
26+
uses: actions/checkout@v5
27+
- name: setup go
28+
uses: actions/setup-go@v5
29+
with:
30+
go-version: ${{ matrix.go-version }}
31+
- name: run tests
32+
run: go test ./...

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
2. Fork the repository on GitHub.
2323
3. Clone your forked repository to your local machine.
2424
4. Create a new branch for your changes.
25-
5. Complete an issue and commit it.
25+
5. Install dependencies with `make build` (required to have `make` and `go` (version from go.mod) installed)
26+
6. Complete an issue and commit it.
2627
- Follow the [style guide](https://google.github.io/styleguide/go/guide).
2728
- Test your code thoroughly.
2829
- Write clear and concise commit messages.
29-
6. Push your changes to your forked repository.
30-
7. Create a pull request to the main repository.
30+
7. Push your changes to your forked repository.
31+
8. Create a pull request to the main repository.
3132
- Pull request will not be merged until it is approved by a maintainer and passes all checks.
3233

3334
*[List of code contributors] is updated weekly.*

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
.DEFAULT_GOAL := check
2+
3+
check: lint test
4+
15
lint:
26
go tool golangci-lint run
37

8+
build:
9+
go mod download
10+
411
test:
5-
go test -v ./...
12+
go test ./...
613

714
coverage:
815
go test -coverprofile=.coverage ./...
916

1017
clean:
11-
rm .coverage
18+
rm -f .coverage
19+
go clean -testcache

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<a href="https://github.com/statloc/core/issues"><img src="https://img.shields.io/github/issues/statloc/core?style=flat-square&color=purple"></a>
99
<a href="https://github.com/statloc/core/pulls"><img src="https://img.shields.io/github/issues-pr/statloc/core?label=pull%20requests&style=flat-square&color=purple"></a>
1010
<a href="https://github.com/statloc/core/actions/workflows/check.yml/"><img src="https://img.shields.io/github/actions/workflow/status/statloc/core/check.yml?branch=dev/0.1.0&style=flat-square&label=checks&color=purple"></a>
11-
<a href="https://github.com/statloc/core/blob/master/go.mod"><img src="https://img.shields.io/badge/go_version-1.24_%7C_1.25-purple?style=flat-square&label=go%20version&color=purple"></a>
11+
<a href="https://github.com/statloc/core/blob/master/go.mod"><img src="https://img.shields.io/badge/go_version-1.25-purple?style=flat-square&label=go%20version&color=purple"></a>
1212
</div>
1313

1414
### ✏️ About
@@ -37,15 +37,9 @@ func main() {
3737
result := = fmt.Sprintf(
3838
`Statistics(total):
3939
lines of code: %d
40-
files: %d
41-
methods: %d
42-
average lines of code per method: %d
43-
average lines of code per file: %d`,
40+
files: %d`,
4441
total.LOC,
4542
total.Files,
46-
total.Methods,
47-
total.LOCPerMethod,
48-
total.LOCPerFile,
4943
)
5044

5145
fmt.Println(results)

assets/components.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"tests": "Tests"
3+
}

assets/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
".go": "Go",
3+
".py": "Python",
4+
".c": "C",
5+
".cpp": "C++",
6+
".java": "Java",
7+
".rb": "Ruby",
8+
".rs": "Rust"
9+
}

errors.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package statloc
2+
3+
import "fmt"
4+
5+
type PathError struct {
6+
Path string
7+
}
8+
9+
func (e *PathError) Error() string {
10+
return fmt.Sprintf("%s is not a directory", e.Path)
11+
}

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
module statloc
1+
module github.com/statloc/core
22

33
go 1.25.1
44

5+
require github.com/stretchr/testify v1.11.1
6+
57
require (
68
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
79
4d63.com/gochecknoglobals v0.2.2 // indirect
@@ -172,7 +174,6 @@ require (
172174
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
173175
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
174176
github.com/stretchr/objx v0.5.2 // indirect
175-
github.com/stretchr/testify v1.11.1 // indirect
176177
github.com/subosito/gotenv v1.4.1 // indirect
177178
github.com/tetafro/godot v1.5.4 // indirect
178179
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect

go.sum

Lines changed: 52 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package mapping
2+
3+
type InvalidJSON struct {
4+
Message string
5+
}

0 commit comments

Comments
 (0)