tidytypes

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 4 Imported by: 0

README

lesiw.io/tidytypes Go Reference

An analysis.Analyzer that reports redundant type declarations in function parameters and results.

The analyzer identifies consecutive parameters or results with the same type that can be grouped together using Go's type grouping syntax, making code more concise and readable.

Usage (test)

package main

import (
	"testing"

	"lesiw.io/checker"
	"lesiw.io/tidytypes"
)

func TestCheck(t *testing.T) { checker.Run(t, tidytypes.Analyzer) }

Usage (CLI)

go get -tool lesiw.io/tidytypes/cmd/tidytypes
go tool tidytypes ./...

Features

  • Detects redundant type declarations in function parameters and results.
  • Works with both named and unnamed parameters/results
  • Provides automatic fixes via suggested edits
  • Supports function literals and method declarations
  • Preserves existing grouped parameters that are already correct or cannot be reduced

Fixes

  • Consecutive parameters with the same type: func(a int, b int)func(a, b int)
  • Consecutive return values with the same type: func() (int, int)func() (_, _ int)
  • Multiple redundant groups: func(a int, b int, c string, d string)func(a, b int, c, d string)
  • Complex types: func(a []int, b []int)func(a, b []int)
  • Function literals: var fn = func(x int, y int) {}var fn = func(x, y int) {}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "tidytypes",
	Doc:  "reports redundant type declarations in parameters and results",
	Run:  run,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
tidytypes command

Jump to

Keyboard shortcuts

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