godot

package module
v1.4.16 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 9 Imported by: 11

README

godot

License Github CI Go Report Codecov

Linter that checks if all top-level comments contain a period at the end of the last sentence if needed.

CodeReviewComments quote:

Comments should begin with the name of the thing being described and end in a period

Install

NOTE: Godot is available as a part of GolangCI Lint (disabled by default).

Build from source

go install github.com/tetafro/godot/cmd/godot@latest

or download binary from releases page.

Config

You can specify options using config file. Use default name .godot.yaml, or set it using -c filename.yaml argument. If no config provided the following defaults are used:

# Which comments to check:
#   declarations - for top level declaration comments (default);
#   toplevel     - for top level comments;
#   all          - for all comments.
scope: declarations

# List of regexps for excluding particular comment lines from check.
exclude:

# Check periods at the end of sentences.
period: true

# Check that first letter of each sentence is capital.
capital: false

Run

godot ./myproject

Autofix flags are also available

godot -f ./myproject # fix issues and print the result
godot -w ./myproject # fix issues and replace the original file

See all flags with godot -h.

Example

Code

package math

// Sum sums two integers
func Sum(a, b int) int {
    return a + b // result
}

Output

Comment should end in a period: math/math.go:3:1

Documentation

Overview

Package godot checks if comments contain a period at the end of the last sentence if needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fix added in v0.4.0

func Fix(path string, file *ast.File, fset *token.FileSet, settings Settings) ([]byte, error)

Fix fixes all issues and returns new version of file content.

func Replace added in v0.4.0

func Replace(path string, file *ast.File, fset *token.FileSet, settings Settings) error

Replace rewrites original file with its fixed version.

Types

type Issue added in v0.4.0

type Issue struct {
	Pos         token.Position
	Message     string
	Replacement string
}

Issue contains a description of linting error and a recommended replacement.

func Run

func Run(file *ast.File, fset *token.FileSet, settings Settings) ([]Issue, error)

Run runs this linter on the provided code.

type Scope added in v1.0.0

type Scope string

Scope sets which comments should be checked.

const (
	// DeclScope is for top level declaration comments.
	DeclScope Scope = "declarations"
	// TopLevelScope is for all top level comments.
	TopLevelScope Scope = "toplevel"
	// AllScope is for all comments.
	AllScope Scope = "all"
)

List of available check scopes.

type Settings added in v0.2.4

type Settings struct {
	// Which comments to check (top level declarations, top level, all).
	Scope Scope

	// Regexp for excluding particular comment lines from check.
	Exclude []string

	// Check periods at the end of sentences.
	Period bool

	// Check that first letter of each sentence is capital.
	Capital bool
}

Settings contains linter settings.

Directories

Path Synopsis
cmd
godot
godot is a linter that checks if all top-level comments contain a period at the end of the last sentence if needed.
godot is a linter that checks if all top-level comments contain a period at the end of the last sentence if needed.

Jump to

Keyboard shortcuts

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