Skip to content

Commit

Permalink
Merge pull request ignite#1 from tendermint/marko/add_linting
Browse files Browse the repository at this point in the history
add linter and add linting in ci
  • Loading branch information
fadeev authored Jun 24, 2020
2 parents 7ee0929 + 59b4f4a commit 4769a25
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 19 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint
# Lint runs golangci-lint over the entire repository
# This workflow is run on every pull request and push to master
# The `golangci` will pass without running if no *.{go, mod, sum} files have been changed.
on:
pull_request:
push:
branches:
- master
jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
timeout-minutes: 6
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v1
with:
SUFFIX_FILTER: |
.go
.mod
.sum
- uses: golangci/golangci-lint-action@master
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.27
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: "env.GIT_DIFF != ''"
42 changes: 42 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
run:
tests: false
# # timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
# - errcheck
- goconst
- gocritic
- gofmt
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- maligned
- misspell
- nakedret
- prealloc
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- unparam
- misspell
# - wsl
- nolintlint

issues:
max-issues-per-linter: 10000
max-same-issues: 10000
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ install: build ui

cli: build
@go install -mod=readonly ./...

lint:
golangci-lint run --out-format=tab --issues-exit-code=0
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
.PHONY: lint

.PHONY: all mod build ui install
.PHONY: all mod build ui install
6 changes: 3 additions & 3 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func startServe(verbose bool) (*exec.Cmd, *exec.Cmd) {
log.Fatal("Error in initializing the chain. Please, check ./init.sh")
}
fmt.Printf("🎨 Created a web front-end.\n")
cmdTendermint := exec.Command(fmt.Sprintf("%[1]vd", appName), "start")
cmdTendermint := exec.Command(fmt.Sprintf("%[1]vd", appName), "start") //nolint:gosec // Subprocess launched with function call as argument or cmd arguments
if verbose {
fmt.Printf("🌍 Running a server at http://localhost:26657 (Tendermint)\n")
cmdTendermint.Stdout = os.Stdout
Expand All @@ -51,7 +51,7 @@ func startServe(verbose bool) (*exec.Cmd, *exec.Cmd) {
if err := cmdTendermint.Start(); err != nil {
log.Fatal(fmt.Sprintf("Error in running %[1]vd start", appName), err)
}
cmdREST := exec.Command(fmt.Sprintf("%[1]vcli", appName), "rest-server")
cmdREST := exec.Command(fmt.Sprintf("%[1]vcli", appName), "rest-server") //nolint:gosec // Subprocess launched with function call as argument or cmd arguments
if verbose {
fmt.Printf("🌍 Running a server at http://localhost:1317 (LCD)\n")
cmdREST.Stdout = os.Stdout
Expand Down Expand Up @@ -86,7 +86,7 @@ var serveCmd = &cobra.Command{
go func() {
for {
select {
case _ = <-w.Event:
case <-w.Event:
cmdr.Process.Kill()
cmdt.Process.Kill()
cmdt, cmdr = startServe(verbose)
Expand Down
8 changes: 3 additions & 5 deletions templates/app/new.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app

import (
"fmt"
"strings"

"github.com/gobuffalo/genny"
Expand All @@ -20,10 +19,9 @@ func New(opts *Options) (*genny.Generator, error) {
ctx.Set("ModulePath", opts.ModulePath)
ctx.Set("AppName", opts.AppName)
ctx.Set("Denom", opts.Denom)
ctx.Set("title", func(s string) string {
return strings.Title(s)
})
ctx.Set("title", strings.Title)

g.Transformer(plushgen.Transformer(ctx))
g.Transformer(genny.Replace("{{appName}}", fmt.Sprintf("%s", opts.AppName)))
g.Transformer(genny.Replace("{{appName}}", opts.AppName))
return g, nil
}
17 changes: 7 additions & 10 deletions templates/typed/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ func New(opts *Options) (*genny.Generator, error) {
ctx.Set("TypeName", opts.TypeName)
ctx.Set("ModulePath", opts.ModulePath)
ctx.Set("Fields", opts.Fields)
ctx.Set("title", func(s string) string {
return strings.Title(s)
})
ctx.Set("title", strings.Title)
ctx.Set("strconv", func() bool {
strconv := false
for _, field := range opts.Fields {
Expand All @@ -45,15 +43,14 @@ func New(opts *Options) (*genny.Generator, error) {
return strconv
})
g.Transformer(plushgen.Transformer(ctx))
g.Transformer(genny.Replace("{{appName}}", fmt.Sprintf("%s", opts.AppName)))
g.Transformer(genny.Replace("{{typeName}}", fmt.Sprintf("%s", opts.TypeName)))
g.Transformer(genny.Replace("{{TypeName}}", fmt.Sprintf("%s", strings.Title(opts.TypeName))))
g.Transformer(genny.Replace("{{appName}}", opts.AppName))
g.Transformer(genny.Replace("{{typeName}}", opts.TypeName))
g.Transformer(genny.Replace("{{TypeName}}", opts.TypeName))
return g, nil
}

const placeholder = "// this line is used by starport scaffolding"
const placeholder2 = "// this line is used by starport scaffolding # 2"
const placeholder3 = "// this line is used by starport scaffolding # 3"
const placeholder4 = "<!-- this line is used by starport scaffolding # 4 -->"

func handlerModify(opts *Options) genny.RunFn {
Expand Down Expand Up @@ -230,10 +227,10 @@ func uiIndexModify(opts *Options) genny.RunFn {
<div class="type-%[1]v-list-%[1]v"></div>
<h3>Create a new %[1]v:</h3>`, opts.TypeName)
for _, field := range opts.Fields {
template = template + fmt.Sprintf(`
template += fmt.Sprintf(`
<input placeholder="%[1]v" class="type-%[2]v-field-%[1]v" type="text" />`, field.Name, opts.TypeName)
}
template = template + fmt.Sprintf(`
template += fmt.Sprintf(`
<button class="type-%[1]v-create">Create %[1]v</button>
`, opts.TypeName) + " " + placeholder4
content := strings.Replace(f.String(), placeholder4, template, 1)
Expand All @@ -251,7 +248,7 @@ func uiScriptModify(opts *Options) genny.RunFn {
}
fields := ""
for _, field := range opts.Fields {
fields = fields + fmt.Sprintf("\"%[1]v\", ", field.Name)
fields += fmt.Sprintf("\"%[1]v\", ", field.Name)
}
template := `%[1]v
["%[2]v", [%[3]v]],`
Expand Down

0 comments on commit 4769a25

Please sign in to comment.