Skip to content

Commit

Permalink
Remove all linter excluding rules, fix all linter issues that appeare…
Browse files Browse the repository at this point in the history
…d after removal. Make some code cleanup.
  • Loading branch information
nkryuchkov committed Jul 14, 2019
1 parent 354a06c commit 156bb42
Show file tree
Hide file tree
Showing 84 changed files with 914 additions and 381 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
.idea/

/skywire.json
/*-config.json
/apps/
/skywire/
/local*
Expand Down
6 changes: 1 addition & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ issues:
# it can be disabled by `exclude-use-default: false`. To list all
# excluded by default patterns execute `golangci-lint run --help`
exclude:
- "G304: Potential file inclusion via variable"
- "G204: Subprocess launched with variable"
- "G104: Errors unhandled"
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
Expand All @@ -192,4 +188,4 @@ issues:
# large codebase. It's not practical to fix all existing issues at the moment
# of integration: much better don't allow issues in new code.
# Default is false.
new: false
new: false
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
- [2. Get an IP of node](#2-get-an-ip-of-node)
- [3. Open in browser containerized `skychat` application](#3-open-in-browser-containerized-skychat-application)
- [4. Create new dockerized `skywire-nodes`](#4-create-new-dockerized-skywire-nodes)
- [5. Env-vars for develoment-/testing- purposes](#5-env-vars-for-develoment-testing--purposes)
- [5. Env-vars for development-/testing- purposes](#5-env-vars-for-development-testing--purposes)
- [6. "Hello-Mike-Hello-Joe" test](#6-hello-mike-hello-joe-test)

## Notes on this release
Expand Down Expand Up @@ -424,7 +424,7 @@ Instead of skywire-runner you can use:
- `golang`, `buildpack-deps:stretch-scm` "as is"
- and `debian`, `ubuntu` - after `apt-get install ca-certificates` in them. Look in `skywire-runner.Dockerfile` for example

#### 5. Env-vars for develoment-/testing- purposes
#### 5. Env-vars for development-/testing- purposes

```bash
export SW_NODE_A=127.0.0.1
Expand Down
4 changes: 2 additions & 2 deletions ci_scripts/run-internal-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m

go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealproxy -run TestProxy >> ./logs/internal/TestProxy.log

go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealssh -run TestListAuthoriser >> ./logs/internal/TestListAuthoriser.log
go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealssh -run TestFileAuthoriser >> ./logs/internal/TestFileAuthoriser.log
go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealssh -run TestListAuthorizer >> ./logs/internal/TestListAuthorizer.log
go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealssh -run TestFileAuthorizer >> ./logs/internal/TestFileAuthorizer.log
go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealssh -run TestChannelServe >> ./logs/internal/TestChannelServe.log
go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealssh -run TestChannelSendWrite >> ./logs/internal/TestChannelSendWrite.log
go clean -testcache &>/dev/null || go test -race -tags no_ci -cover -timeout=5m github.com/skycoin/skywire/internal/therealssh -run TestChannelRead >> ./logs/internal/TestChannelRead.log
Expand Down
6 changes: 5 additions & 1 deletion cmd/apps/helloworld/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ func main() {
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer helloworldApp.Close()
defer func() {
if err := helloworldApp.Close(); err != nil {
log.Println("Failed to close app: ", err)
}
}()

if len(os.Args) == 1 {
log.Println("listening for incoming connections")
Expand Down
4 changes: 4 additions & 0 deletions cmd/apps/skychat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Create 2 node config files:
`skywire1.json`

```json
{
"apps": [
{
"app": "skychat",
Expand All @@ -21,11 +22,13 @@ Create 2 node config files:
"port": 1
}
]
}
```

`skywire2.json`

```json
{
"apps": [
{
"app": "skychat",
Expand All @@ -35,6 +38,7 @@ Create 2 node config files:
"args": ["-addr", ":8001"]
}
]
}
```

Compile binaries and start 2 nodes:
Expand Down
11 changes: 9 additions & 2 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ func main() {
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer func() { _ = a.Close() }()
defer func() {
if err := a.Close(); err != nil {
log.Println("Failed to close app: ", err)
}
}()

chatApp = a

Expand Down Expand Up @@ -83,7 +87,10 @@ func handleConn(conn net.Conn) {
return
}

clientMsg, _ := json.Marshal(map[string]string{"sender": raddr.PubKey.Hex(), "message": string(buf[:n])}) // nolint
clientMsg, err := json.Marshal(map[string]string{"sender": raddr.PubKey.Hex(), "message": string(buf[:n])})
if err != nil {
log.Printf("Failed to marshal json: %v", err)
}
select {
case clientCh <- string(clientMsg):
log.Printf("received and sent to ui: %s\n", clientMsg)
Expand Down
6 changes: 5 additions & 1 deletion cmd/apps/therealproxy-client/therealproxy-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ func main() {
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer socksApp.Close()
defer func() {
if err := socksApp.Close(); err != nil {
log.Println("Failed to close app: ", err)
}
}()

if *serverPK == "" {
log.Fatal("Invalid server PubKey")
Expand Down
4 changes: 4 additions & 0 deletions cmd/apps/therealproxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Create 2 node config files:
- `skywire1.json`

```json
{
"apps": [
{
"app": "socksproxy",
Expand All @@ -24,11 +25,13 @@ Create 2 node config files:
"args": ["-passcode", "123456"]
}
]
}
```

- `skywire2.json`

```json
{
"apps": [
{
"app": "socksproxy-client",
Expand All @@ -38,6 +41,7 @@ Create 2 node config files:
"args": ["-srv", "024ec47420176680816e0406250e7156465e4531f5b26057c9f6297bb0303558c7"]
}
]
}
```

Compile binaries and start 2 nodes:
Expand Down
6 changes: 5 additions & 1 deletion cmd/apps/therealproxy/therealproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ func main() {
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer socksApp.Close()
defer func() {
if err := socksApp.Close(); err != nil {
log.Println("Failed to close app: ", err)
}
}()

srv, err := therealproxy.NewServer(*passcode)
if err != nil {
Expand Down
12 changes: 10 additions & 2 deletions cmd/apps/therealssh-client/therealssh-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ func main() {
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer sshApp.Close()
defer func() {
if err := sshApp.Close(); err != nil {
log.Println("Failed to close app: ", err)
}
}()

ssh.Debug = *debug

rpc, client, err := ssh.NewClient(*rpcAddr, sshApp)
if err != nil {
log.Fatal("Client setup failure: ", err)
}
defer client.Close()
defer func() {
if err := client.Close(); err != nil {
log.Println("Failed to close client: ", err)
}
}()

if err := http.Serve(rpc, nil); err != nil {
log.Fatal("Failed to start RPC interface: ", err)
Expand Down
8 changes: 6 additions & 2 deletions cmd/apps/therealssh/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Create 2 node config files:
`skywire1.json`

```json
{
"apps": [
{
"app": "SSH",
Expand All @@ -28,11 +29,13 @@ Create 2 node config files:
"port": 2
}
]
}
```

`skywire2.json`

```json
{
"apps": [
{
"app": "SSH-client",
Expand All @@ -41,6 +44,7 @@ Create 2 node config files:
"port": 22
}
]
}
```

Compile binaries and start 2 nodes:
Expand All @@ -56,8 +60,8 @@ $ ./skywire-node skywire2.json
Add public key of the second node to the auth file:

```bash
$ mkdir `/.therealssh
$ echo "0348c941c5015a05c455ff238af2e57fb8f914c399aab604e9abb5b32b91a4c1fe" > `/.SSH/authorized_keys
$ mkdir /.therealssh
$ echo "0348c941c5015a05c455ff238af2e57fb8f914c399aab604e9abb5b32b91a4c1fe" > /.SSH/authorized_keys
```

Connect to the first node using CLI:
Expand Down
16 changes: 12 additions & 4 deletions cmd/apps/therealssh/therealssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"flag"
"log"

homedir "github.com/mitchellh/go-homedir"
"github.com/mitchellh/go-homedir"

ssh "github.com/skycoin/skywire/internal/therealssh"
"github.com/skycoin/skywire/pkg/app"
Expand All @@ -24,7 +24,11 @@ func main() {
if err != nil {
log.Fatal("Setup failure: ", err)
}
defer sshApp.Close()
defer func() {
if err := sshApp.Close(); err != nil {
log.Println("Failed to close app: ", err)
}
}()

path, err := homedir.Expand(*authFile)
if err != nil {
Expand All @@ -35,11 +39,15 @@ func main() {

auth, err := ssh.NewFileAuthorizer(path)
if err != nil {
log.Fatal("Failed to setup Authoriser: ", err)
log.Fatal("Failed to setup Authorizer: ", err)
}

server := ssh.NewServer(auth)
defer server.Close()
defer func() {
if err := server.Close(); err != nil {
log.Println("Failed to close server: ", err)
}
}()

for {
conn, err := sshApp.Accept()
Expand Down
7 changes: 4 additions & 3 deletions cmd/messaging-server/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"net"
"net/http"
"os"
"path/filepath"

"github.com/prometheus/client_golang/prometheus/promhttp"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/dmsg"
"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/dmsg/disc"
Expand Down Expand Up @@ -56,7 +57,7 @@ var rootCmd = &cobra.Command{
logging.SetLevel(logLevel)

if syslogAddr != "" {
hook, err := logrus_syslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
Expand Down Expand Up @@ -97,7 +98,7 @@ func parseConfig(configFile string) *Config {
var rdr io.Reader
var err error
if !cfgFromStdin {
rdr, err = os.Open(configFile)
rdr, err = os.Open(filepath.Clean(configFile))
if err != nil {
log.Fatalf("Failed to open config: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/setup-node/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"os"

"github.com/prometheus/client_golang/prometheus/promhttp"
logrus_syslog "github.com/sirupsen/logrus/hooks/syslog"
logrussyslog "github.com/sirupsen/logrus/hooks/syslog"
"github.com/skycoin/skycoin/src/util/logging"
"github.com/spf13/cobra"

Expand All @@ -33,7 +33,7 @@ var rootCmd = &cobra.Command{

logger := logging.MustGetLogger(tag)
if syslogAddr != "" {
hook, err := logrus_syslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
hook, err := logrussyslog.NewSyslogHook("udp", syslogAddr, syslog.LOG_INFO, tag)
if err != nil {
logger.Fatalf("Unable to connect to syslog daemon on %v", syslogAddr)
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/skywire-cli/commands/node/gen-config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ func defaultConfig() *node.Config {
conf.Transport.LogStore.Location = "./skywire/transport_logs"

conf.Routing.RouteFinder = "https://routefinder.skywire.skycoin.net/"

const defaultSetupNodePK = "0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557"
sPK := cipher.PubKey{}
sPK.UnmarshalText([]byte("0324579f003e6b4048bae2def4365e634d8e0e3054a20fc7af49daf2a179658557")) // nolint: errcheck
if err := sPK.UnmarshalText([]byte(defaultSetupNodePK)); err != nil {
log.WithError(err).Warnf("Failed to unmarshal default setup node public key %s", defaultSetupNodePK)
}
conf.Routing.SetupNodes = []cipher.PubKey{sPK}
conf.Routing.Table.Type = "boltdb"
conf.Routing.Table.Location = "./skywire/routing.db"
Expand Down
6 changes: 5 additions & 1 deletion cmd/skywire-cli/commands/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package commands

import (
"log"

"github.com/spf13/cobra"

"github.com/skycoin/skywire/cmd/skywire-cli/commands/mdisc"
Expand All @@ -25,5 +27,7 @@ func init() {

// Execute executes root CLI command.
func Execute() {
_ = rootCmd.Execute() //nolint:errcheck
if err := rootCmd.Execute(); err != nil {
log.Fatal("Failed to execute command: ", err)
}
}
Loading

0 comments on commit 156bb42

Please sign in to comment.