Ejemplo n.º 1
0
func main() {
	// Parse and handle all flags
	args := os.Args
	fileName, err := input.ParseFlags(args)
	if err != nil {
		fmt.Println("gocomment error: could not parse arguments")
		os.Exit(1)
	}

	// Get all lines for given directory
	lines, err := input.GetFileLines(fileName)
	if err != nil {
		log.Fatalln("could not get source code from " + fileName)
	}

	os.Exit(lint.Run(lines))
}
Ejemplo n.º 2
0
package lint_test

import (
	"github.build.ge.com/212472270/gocomment/input"
	"github.build.ge.com/212472270/gocomment/lint"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Input", func() {

	Describe("Given lint has been ran with valid flags on a golang file", func() {
		Context("when said file has any line comments with incorrect format", func() {
			It("should return 1", func() {
				lines, err := input.GetFileLines("../test_comments/badcomments.go")
				Expect(err).NotTo(HaveOccurred())

				Expect(lint.Run(lines)).To(Equal(1))
			})
		})

		Context("when said file has no line comments with incorrect format", func() {
			It("should return 0", func() {
				lines, err := input.GetFileLines("../test_comments/goodcomments.go")
				Expect(err).NotTo(HaveOccurred())

				Expect(lint.Run(lines)).To(Equal(0))
			})
		})
	})
Ejemplo n.º 3
0
package input_test

import (
	"github.build.ge.com/212472270/gocomment/input"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"testing"
)

func TestInput(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Input Suite")
}

var _ = BeforeSuite(func() {
	var err error
	fileName = "../test_comments/comment.go"
	fileLines, err = input.GetFileLines(fileName)
	Expect(err).NotTo(HaveOccurred())

})