Giter VIP home page Giter VIP logo

impi's People

Contributors

jasonhancock avatar nick-jones avatar pavius avatar tebeka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

impi's Issues

Deadlock when using invalid local prefix path

I noticed whilst testing changes over the weekend that a deadlock can occur if a local prefix is supplied that doesn't match any import (unsure what the exact reason is at this stage). This occurs on v0.0.1 so it's not linked to any recent changes. I'm happy to take a look at some point, just raising for visibility at the moment.

$ /Users/nicholas/Dev/impi/cmd/impi/impi --local github.com/invalid/prefix --scheme stdThirdPartyLocal --ignore-generated=true ./...
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan send]:
github.com/pavius/impi.(*Impi).addFilePathToFilePathsChan(0xc00004a3c0, 0xc0004106c0, 0x25)
	/Users/nicholas/Dev/impi/impi.go:254 +0x1df
github.com/pavius/impi.(*Impi).populatePathsChan(0xc00004a3c0, 0x7ffeefbffa8d, 0x5, 0x0, 0x135a008)
	/Users/nicholas/Dev/impi/impi.go:144 +0x29b
github.com/pavius/impi.(*Impi).Verify(0xc00004a3c0, 0x7ffeefbffa8d, 0x5, 0xc00004a400, 0x11d1020, 0x1306c10, 0x15, 0xc0000403e0)
	/Users/nicholas/Dev/impi/impi.go:105 +0x162
main.run(0x17, 0xc000097f58)
	/Users/nicholas/Dev/impi/cmd/impi/main.go:70 +0x405
main.main()
	/Users/nicholas/Dev/impi/cmd/impi/main.go:92 +0x41

goroutine 4 [chan send]:
github.com/pavius/impi.(*Impi).verifyPathsFromChan(0xc00004a3c0, 0x118a660, 0x60)
	/Users/nicholas/Dev/impi/impi.go:215 +0x18b
created by github.com/pavius/impi.(*Impi).createWorkers
	/Users/nicholas/Dev/impi/impi.go:184 +0x48

goroutine 5 [chan send]:
github.com/pavius/impi.(*Impi).verifyPathsFromChan(0xc00004a3c0, 0x118a660, 0x60)
	/Users/nicholas/Dev/impi/impi.go:215 +0x18b
created by github.com/pavius/impi.(*Impi).createWorkers
	/Users/nicholas/Dev/impi/impi.go:184 +0x48

goroutine 6 [chan send]:
github.com/pavius/impi.(*Impi).verifyPathsFromChan(0xc00004a3c0, 0x118a660, 0x60)
	/Users/nicholas/Dev/impi/impi.go:215 +0x18b
created by github.com/pavius/impi.(*Impi).createWorkers
	/Users/nicholas/Dev/impi/impi.go:184 +0x48

goroutine 7 [chan send]:
github.com/pavius/impi.(*Impi).verifyPathsFromChan(0xc00004a3c0, 0x118a660, 0x60)
	/Users/nicholas/Dev/impi/impi.go:215 +0x18b
created by github.com/pavius/impi.(*Impi).createWorkers
	/Users/nicholas/Dev/impi/impi.go:184 +0x48

Ignore C directive in comments before 'import "C"`

If we have code like:

import (
	"fmt"
	"net/http"
	"os"
	goruntime "runtime"
	"strings"
	"unsafe"

	"github.com/nuclio/nuclio/pkg/errors"
	"github.com/nuclio/nuclio/pkg/processor/runtime"

	"github.com/nuclio/logger"
	"github.com/nuclio/nuclio-sdk-go"
)

/*
#include <Python.h>
#include <stdlib.h>
#include "types.h"

extern response_t call_handler(unsigned long event_ptr, unsigned long logger_ptr);
extern char *py_last_error();
void free_response_t(response_t response);
*/
import "C"

Then impi thinks there are 4 import groups due to the empty line in the comment before `import "C"

$ impi --local github.com/nuclio/nuclio/ --scheme stdLocalThirdParty ./cmd/... ./pkg/...
pkg/processor/runtime/python3/runtime.go: Expected no more than 3 groups, got 4

If we remove the empty line after #include "types.h" then impi is happy.

inlined nosec comments fails linting

This example, should pass (I hope):

test.go

package test

import (
	"crypto/hmac"
	"crypto/md5"  // #nosec
	"crypto/sha1" // #nosec
	"encoding/base64"
)

but it fails: $ impi --scheme stdThirdPartyLocal test.go

- Import group 0 is not sorted
-- Got:
crypto/hmac
 // #nosec
// #nosec
encoding/base64

-- Expected:
 // #nosec
// #nosec
crypto/hmac
encoding/base64

We need to inline the // #nosec on import statements (for gosec -- "safe" usage of md5/sha1 in out codebase). This utility is conflicting with gofumpt and gosec -- can't make all three happy simultaneously :)

I believe this utility should allow inline comments on import statements. From the Got/Expected output, it seems this linter is eating the imported package name and trying to sort based on the inline'd comment...

ignore generated files

It would be nice to have an option to skip files that have the standard header comment indicating they were generated with a code generator:

// Code generated by moq; DO NOT EDIT.
// github.com/matryer/moq

How to handle gofmt, golint and impi at the same time?

import (
	"io"
	"io/ioutil"
	"net/textproto"
	"strings"

	imap "github.com/emersion/go-imap"
	"github.com/emersion/go-imap/client"

	// register all charsets
	_ "github.com/emersion/go-message/charset"
	"github.com/emersion/go-message/mail"
	"github.com/pkg/errors"

	"github.com/agflow/agflow/pkg/log"
	"github.com/agflow/agflow/pkg/util/convert"
)

In the above code, golint requires comment, gofmt puts blank line then impi complains. How to handle this case?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.