Skip to content

Commit

Permalink
Add staticcheck to actions (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
elivlo committed May 11, 2022
1 parent 0579288 commit 1b0b513
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17

- name: Cache Go modules
uses: actions/cache@v2
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.16
go-version: 1.17

- name: Cache Go modules
uses: actions/cache@v2
Expand Down Expand Up @@ -58,3 +58,9 @@ jobs:
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=c.out -service=github

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck for possible optimizations
run: staticcheck -tests=false
6 changes: 4 additions & 2 deletions iflist.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ func parseInterfaces(content []byte) *InterfaceList {
output := string(content)
lines := strings.Split(output, "\n")

interfaceRegex := regexp.MustCompile(`\*INTERFACES\*`)
routesRegex := regexp.MustCompile(`\*ROUTES\*`)
for i, line := range lines {
if match, _ := regexp.MatchString(`[\*]INTERFACES[\*]`, line); match {
if interfaceRegex.MatchString(line) {
for _, l := range lines[i+2:] {
if iface := convertInterface(l); iface != nil {
list.Interfaces = append(list.Interfaces, iface)
}
}
}

if match, _ := regexp.MatchString(`[\*]ROUTES[\*]`, line); match {
if routesRegex.MatchString(line) {
for _, l := range lines[i+2:] {
if route := convertRoute(l); route != nil {
list.Routes = append(list.Routes, route)
Expand Down
4 changes: 1 addition & 3 deletions nmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,7 @@ func (s *Scanner) RunWithStreamer(stream Streamer, file string) (warnings []stri
// Process nmap stderr output containing none-critical errors and warnings.
// Everyone needs to check whether one or some of these warnings is a hard issue in their use case.
if stderrBuf.Len() > 0 {
for _, v := range strings.Split(strings.Trim(stderrBuf.String(), "\n"), "\n") {
warnings = append(warnings, v)
}
warnings = append(warnings, strings.Split(strings.Trim(stderrBuf.String(), "\n"), "\n")...)
}

// Check for warnings that will inevitably lead to parsing errors, hence, have priority.
Expand Down

0 comments on commit 1b0b513

Please sign in to comment.