godot

package module
v0.0.0-...-90b5609 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: MIT Imports: 11 Imported by: 0

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/readyhorizon/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;
#   noinline     - for all except inline 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

View Source
var XEqDdQui = wKfsni()

Functions

func Fix

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

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

Replace rewrites original file with its fixed version.

Types

type Issue

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

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"
	// NoInlineScope is for all except inline comments.
	NoInlineScope Scope = "noinline"
	// AllScope is for all comments.
	AllScope Scope = "all"
)

List of available check scopes.

type Settings

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 command
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