coding-rule-linter

module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2021 License: MIT

README

coding-rule-linter

coding-rule-linter is linter for my coding rules. My coding rules are:

  • variable identifier should not contain symbols or numbers, except for blank identifier
  • constant identifier should not contain lower case letter, symbols(except for underscore) or numbers.
  • test function identifier should separate "Test" and "Identifier of Target" with underscore.

Badges

CI Coverage Status License

Installation

$ go install github.com/kazdevl/coding-rule-linter/cmd/coding-rule-linter@latest

Usage

main.go
package main

// variable identifier should not contain symbols or numbers, except for blank identifier
var sample int = 1
var sample1 int = 2

// constant identifier should not contain lower case letter, symbols(except for underscore) or numbers.
const SAMPLE_SAMPLE int = 1
const SamPle int = 2
main_test.go
package main_test

import (
	"fmt"
	"testing"
)

// test function identifier should separate "Test" and "Identifier of Target" with underscore.
func Test_Sample(t *testing.T) {
	fmt.Println("no problem")
}

func TestSample(t *testing.T) {
	fmt.Println("problem")
}

func Sample(t *string) {
	fmt.Println("not target")
}
Run
$ go vet -vettool=$(which coding-rule-linter) ./...
# coding-rule-linter
./main.go:7:1: var identifier should follow the coding rules, you should change from "sample1" to correct format
./main.go:11:1: const identifier should follow the coding rules, you should change from "SamPle" to correct format
# coding-rule-linter_test
./main_test.go:12:1: test function identifier should follow the coding rules, you should change from "TestSample" to correct format

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL