formatter

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package formatter provides functionality for formatting lint issues in a human-readable format. It includes various formatters for different types of issues and utility functions for text manipulation.

Index

Constants

View Source
const (
	UnnecessaryElse     = "unnecessary-else"
	UnnecessaryTypeConv = "unnecessary-type-conversion"
	SimplifySliceExpr   = "simplify-slice-range"
	CycloComplexity     = "high-cyclomatic-complexity"
)

rule set

Variables

This section is empty.

Functions

func FormatIssuesWithArrows

func FormatIssuesWithArrows(issues []tt.Issue, snippet *internal.SourceCode) string

FormatIssuesWithArrows formats a slice of issues into a human-readable string. It uses the appropriate formatter for each issue based on its rule.

Types

type CyclomaticComplexityFormatter

type CyclomaticComplexityFormatter struct{}

func (*CyclomaticComplexityFormatter) Format

func (f *CyclomaticComplexityFormatter) Format(issue tt.Issue, snippet *internal.SourceCode) string

type GeneralIssueFormatter

type GeneralIssueFormatter struct{}

GeneralIssueFormatter is a formatter for general lint issues.

func (*GeneralIssueFormatter) Format

func (f *GeneralIssueFormatter) Format(
	issue tt.Issue,
	snippet *internal.SourceCode,
) string

Format formats a general lint issue into a human-readable string. It takes an Issue and a SourceCode snippet as input and returns a formatted string.

type IssueFormatter

type IssueFormatter interface {
	Format(issue tt.Issue, snippet *internal.SourceCode) string
}

IssueFormatter is the interface that wraps the Format method. Implementations of this interface are responsible for formatting specific types of lint issues.

type SimplifySliceExpressionFormatter

type SimplifySliceExpressionFormatter struct{}

func (*SimplifySliceExpressionFormatter) Format

func (f *SimplifySliceExpressionFormatter) Format(
	issue tt.Issue,
	snippet *internal.SourceCode,
) string

type UnnecessaryElseFormatter

type UnnecessaryElseFormatter struct{}

UnnecessaryElseFormatter is a formatter specifically designed for the "unnecessary-else" rule.

func (*UnnecessaryElseFormatter) Format

func (f *UnnecessaryElseFormatter) Format(
	issue tt.Issue,
	snippet *internal.SourceCode,
) string

type UnnecessaryTypeConversionFormatter

type UnnecessaryTypeConversionFormatter struct{}

func (*UnnecessaryTypeConversionFormatter) Format

func (f *UnnecessaryTypeConversionFormatter) Format(
	issue tt.Issue,
	snippet *internal.SourceCode,
) string

Jump to

Keyboard shortcuts

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