Skip to content

Commit

Permalink
feat: add support for file display
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Sep 18, 2020
1 parent 34a6380 commit 7d01a89
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ android-layout-inspector,2533
#### Cloc Top File

```bash
coca cloc ~/intellij-community/android/designer/src/com/android/tools/idea --top-file
coca cloc ~/intellij-community/android/designer/src/com/android/tools/idea --top-file --top-size 10
```

output to: `coca_reporter/sort_cloc.json`
output to: `coca_reporter/sort_cloc.json` and also:

```
```

### Build Deps Tree

Expand Down
7 changes: 4 additions & 3 deletions cmd/cloc.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ func processTopFile(dir string) {

cloc_app.SortLangeByCode(languageSummaries)

if len(languageSummaries) <= 3 {
if len(languageSummaries) <= 5 {
for _, summary := range languageSummaries {
fmt.Fprintln(output, "Language: "+summary.Name)
table := cmd_util.NewOutput(output)
table.SetHeader([]string{"Length", "File", "Complexity", "WeightedComplexity"})
table.SetHeader([]string{"Length", "Complexity", "Location"})
sizes := len(summary.Files)
if sizes >= clocConfig.TopSizes {
sizes = clocConfig.TopSizes
}

for _, file := range summary.Files[:sizes] {
table.Append([]string{strconv.Itoa(int(file.Code)), file.Language, strconv.Itoa(int(file.Complexity)), strconv.Itoa(int(file.WeightedComplexity))})
location := strings.TrimLeft(file.Location, dir)
table.Append([]string{strconv.Itoa(int(file.Code)), strconv.Itoa(int(file.Complexity)), location})
}
table.Render()
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/testdata/top_file.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Language: Java
| LENGTH | FILE | COMPLEXITY | WEIGHTEDCOMPLEXITY |
|--------|------|------------|--------------------|
| 40 | Java | 0 | 0 |
| 19 | Java | 0 | 0 |
| 13 | Java | 0 | 0 |
| 4 | Java | 0 | 0 |
| LENGTH | COMPLEXITY | LOCATION |
|--------|------------|----------------------------|
| 40 | 0 | actory/Bee.java |
| 19 | 0 | builder/Bee.java |
| 13 | 0 | polymorphism/Overload.java |
| 4 | 0 | atic/StaticMain.java |

0 comments on commit 7d01a89

Please sign in to comment.