Esempio 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))
}
Esempio n. 2
0
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))
			})
		})
	})

	Describe("Given gocomment has valid flags sent to it and comments have been properly extracted", func() {
		Context("when a line comment is longer than the default value of 80", func() {