Skip to content

Commit

Permalink
hopefully final commit for 2.13 release
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Sep 7, 2020
1 parent aab6f28 commit 8b2b427
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 23 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,28 @@ You can control the average line byte size using `--min-gen-line-length` such as

You can exclude minified files from the count totally using the flag `--no-min-gen`. Files which match the minified check will be excluded from the output.

### Remapping

Some files may not have an extension. They will be checked to see if they are a #! file. If they are then the language will be remapped to the
correct language. Otherwise, it will not process.

However, you may have the situation where you want to remap such files based on a string inside it. To do so you can use `--remap-unknown`

```
scc --remap-unknown "-*- C++ -*-":"C Header"
```

The above will inspect any file with no extension looking for the string `-*- C++ -*-` and if found remap the file to be counted using the C Header rules.
You can have multiple remap rules if required,

```
scc --remap-unknown "-*- C++ -*-":"C Header","other":"Java"
```

There is als the `--remap-all` parameter which will remap all files.

Note that in all cases if the remap rule does not apply normal #! rules will apply.

### Output Formats

By default `scc` will output to the console. However you can produce output in other formats if you require.
Expand Down
22 changes: 11 additions & 11 deletions SCC-OUTPUT-REPORT.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<tbody><tr>
<th>Go</th>
<th>34</th>
<th>8089</th>
<th>1324</th>
<th>8088</th>
<th>1323</th>
<th>347</th>
<th>6418</th>
<th>1338</th>
<th>321302</th>
<th>321289</th>
</tr><tr>
<th>Java</th>
<th>24</th>
Expand Down Expand Up @@ -48,12 +48,12 @@
</tr><tr>
<th>Markdown</th>
<th>8</th>
<th>1109</th>
<th>257</th>
<th>1131</th>
<th>265</th>
<th>0</th>
<th>852</th>
<th>866</th>
<th>0</th>
<th>45418</th>
<th>46252</th>
</tr><tr>
<th>CSS</th>
<th>5</th>
Expand Down Expand Up @@ -553,11 +553,11 @@
<tfoot><tr>
<th>Total</th>
<th>162</th>
<th>24460</th>
<th>2784</th>
<th>24481</th>
<th>2791</th>
<th>1540</th>
<th>20136</th>
<th>20150</th>
<th>2258</th>
<th>1737243</th>
<th>1738064</th>
</tr></tfoot>
</table></body></html>
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,14 @@ func main() {
"",
"have multiple format output overriding --format [e.g. tabular:stdout,csv:file.csv,json:file.json]",
)

flags.StringVar(
&processor.UnknownRemap,
&processor.RemapUnknown,
"remap-unknown",
"",
"inspect files of unknown type and remap by checking for a string and remapping the language [e.g. \"-*- C++ -*-\":\"C Header\"]",
)
flags.StringVar(
&processor.HardRemap,
&processor.RemapAll,
"remap-all",
"",
"inspect every file and remap by checking for a string and remapping the language [e.g. \"-*- C++ -*-\":\"C Header\"]",
Expand Down
10 changes: 5 additions & 5 deletions processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

// Version indicates the version of the application
var Version = "2.13.0 (beta)"
var Version = "2.13.0"

// Flags set via the CLI which control how the output is displayed

Expand Down Expand Up @@ -103,11 +103,11 @@ var Format = ""
// FormatMulti is a rule for defining multiple output formats
var FormatMulti = ""

// UnknownRemap allows remapping of unknown files with a string to search the content for
var UnknownRemap = ""
// RemapUnknown allows remapping of unknown files with a string to search the content for
var RemapUnknown = ""

// HardRemap allows remapping of all files with a string to search the content for
var HardRemap = ""
// RemapAll allows remapping of all files with a string to search the content for
var RemapAll = ""

// FileOutput sets the file that output should be written to
var FileOutput = ""
Expand Down
8 changes: 4 additions & 4 deletions processor/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,13 +693,13 @@ func processFile(job *FileJob) bool {
job.Language = DetermineLanguage(job.Filename, job.Language, job.PossibleLanguages, job.Content)

remapped := false
if HardRemap != "" {
if RemapAll != "" {
hardRemapLanguage(job)
}

// If the type is #! we should check to see if we can identify
if job.Language == SheBang {
if UnknownRemap != "" {
if RemapUnknown != "" {
remapped = unknownRemapLanguage(job)
}

Expand Down Expand Up @@ -782,7 +782,7 @@ func processFile(job *FileJob) bool {

func hardRemapLanguage(job *FileJob) bool {
remapped := false
for _, s := range strings.Split(HardRemap, ",") {
for _, s := range strings.Split(RemapAll, ",") {
t := strings.Split(s, ":")
if len(t) == 2 {
cutoff := 1000 // 1000 bytes into the file to look
Expand All @@ -808,7 +808,7 @@ func hardRemapLanguage(job *FileJob) bool {

func unknownRemapLanguage(job *FileJob) bool {
remapped := false
for _, s := range strings.Split(UnknownRemap, ",") {
for _, s := range strings.Split(RemapUnknown, ",") {
t := strings.Split(s, ":")
if len(t) == 2 {
cutoff := 1000 // 1000 bytes into the file to look
Expand Down

0 comments on commit 8b2b427

Please sign in to comment.