From 39102ca0713ddc9b9d37ac13b8b42fcebf395300 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 26 Nov 2024 12:23:54 +0300 Subject: [PATCH] Remove codebeat tags --- cron/cron.go | 11 ----------- fmtc/fmtc.go | 4 ---- fsutil/list.go | 5 ----- options/options.go | 7 ------- signal/signal.go | 4 ---- spellcheck/spellcheck.go | 5 ----- system/info_cpu_linux.go | 9 --------- system/info_fs_linux.go | 4 ---- system/info_loadavg_linux.go | 4 ---- system/info_memory_linux.go | 4 ---- system/info_net_linux.go | 4 ---- system/process/process_cpu.go | 8 -------- system/process/process_memory.go | 4 ---- system/process/process_mount.go | 4 ---- timeutil/timeutil.go | 10 ---------- 15 files changed, 87 deletions(-) diff --git a/cron/cron.go b/cron/cron.go index 332070f5..f65608f6 100644 --- a/cron/cron.go +++ b/cron/cron.go @@ -88,8 +88,6 @@ var info = []exprInfo{ // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // Parse parse cron expression // https://en.wikipedia.org/wiki/Cron func Parse(expr string) (*Expr, error) { @@ -142,12 +140,8 @@ func Parse(expr string) (*Expr, error) { return result, nil } -// codebeat:enable[LOC,ABC] - // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC] - // IsDue check if current moment is match for expression func (e *Expr) IsDue(args ...time.Time) bool { if e == nil { @@ -185,9 +179,6 @@ func (e *Expr) IsDue(args ...time.Time) bool { return true } -// I don't have an idea how we can implement this without this conditions -// codebeat:disable[BLOCK_NESTING,LOC,CYCLO] - // Next get time of next matched moment func (e *Expr) Next(args ...time.Time) time.Time { if e == nil { @@ -308,8 +299,6 @@ func (e *Expr) Prev(args ...time.Time) time.Time { return time.Unix(0, 0) } -// codebeat:enable[BLOCK_NESTING,LOC,CYCLO] - // String return raw expression func (e *Expr) String() string { if e == nil { diff --git a/fmtc/fmtc.go b/fmtc/fmtc.go index 3779fc61..5eee0474 100644 --- a/fmtc/fmtc.go +++ b/fmtc/fmtc.go @@ -381,8 +381,6 @@ func IsTag(tag string) bool { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,BLOCK_NESTING] - func tag2ANSI(tag string, clean bool) string { switch { case clean: @@ -449,8 +447,6 @@ func tag2ANSI(tag string, clean bool) string { return fmt.Sprintf("\033[" + chars[:len(chars)-1] + "m") } -// codebeat:enable[LOC,BLOCK_NESTING] - func parseExtendedColor(tag string) string { if len(tag) == 7 { hex := strings.TrimLeft(tag, "#%") diff --git a/fsutil/list.go b/fsutil/list.go index 8d0963e2..95186af9 100644 --- a/fsutil/list.go +++ b/fsutil/list.go @@ -266,9 +266,6 @@ func readDirRecFiles(path, base string, ignoreHidden bool, filter ListingFilter) return result } -// It's ok to have long function with many conditions to filter some entities -// codebeat:disable[LOC,ABC,CYCLO] - func isMatch(name, fullPath string, filter ListingFilter) bool { var ( hasNotMatchPatterns = filter.hasNotMatchPatterns() @@ -379,8 +376,6 @@ func isMatch(name, fullPath string, filter ListingFilter) bool { return match } -// codebeat:enable[LOC,ABC,CYCLO] - func filterList(names []string, dir string, filter ListingFilter) []string { var filteredNames []string diff --git a/options/options.go b/options/options.go index 899edf5e..a88bd8ab 100644 --- a/options/options.go +++ b/options/options.go @@ -673,11 +673,6 @@ func (o optionName) String() string { // ////////////////////////////////////////////////////////////////////////////////// // -// I think it is okay to have such a long and complicated method for parsing data -// because it has a lot of logic which can't be separated into different methods -// without losing code readability -// codebeat:disable[LOC,BLOCK_NESTING,CYCLO] - func (o *Options) parseOptions(rawOpts []string) (Arguments, errors.Errors) { o.prepare() @@ -784,8 +779,6 @@ func (o *Options) parseOptions(rawOpts []string) (Arguments, errors.Errors) { return arguments, errs } -// codebeat:enable[LOC,BLOCK_NESTING,CYCLO] - func (o *Options) parseLongOption(opt string) (string, string, error) { if strings.Contains(opt, "=") { optName, optValue, ok := strings.Cut(opt, "=") diff --git a/signal/signal.go b/signal/signal.go index 210aadd3..b531cd29 100644 --- a/signal/signal.go +++ b/signal/signal.go @@ -113,8 +113,6 @@ func (h Handlers) TrackAsync() { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // GetByName returns signal with given name func GetByName(name string) (syscall.Signal, error) { switch strings.ToUpper(name) { @@ -245,6 +243,4 @@ func GetByCode(code int) (syscall.Signal, error) { return syscall.Signal(-1), fmt.Errorf("Unknown signal code %d", code) } -// codebeat:enable[LOC,ABC] - // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/spellcheck/spellcheck.go b/spellcheck/spellcheck.go index df483c41..63a133c9 100644 --- a/spellcheck/spellcheck.go +++ b/spellcheck/spellcheck.go @@ -122,9 +122,6 @@ func (m *Model) Suggest(word string, max int) []string { // ////////////////////////////////////////////////////////////////////////////////// // -// I don't have an idea how we could separate this method -// codebeat:disable[LOC,ABC,CYCLO] - // Damerau–Levenshtein distance algorithm and code func getDLDistance(source, target string) int { sl, tl := len(source), len(target) @@ -187,8 +184,6 @@ func getDLDistance(source, target string) int { return h[sl+1][tl+1] } -// codebeat:enable[LOC,ABC,CYCLO] - func getSuggestSlice(terms []string, word string) suggestItems { var result suggestItems diff --git a/system/info_cpu_linux.go b/system/info_cpu_linux.go index db6cb881..a511b8a2 100644 --- a/system/info_cpu_linux.go +++ b/system/info_cpu_linux.go @@ -55,9 +55,6 @@ func GetCPUUsage(duration time.Duration) (*CPUUsage, error) { return CalculateCPUUsage(c1, c2), nil } -// It's ok to have so complex method for calculation -// codebeat:disable[CYCLO] - // CalculateCPUUsage calculates CPU usage based on CPUStats func CalculateCPUUsage(c1, c2 *CPUStats) *CPUUsage { prevIdle := c1.Idle + c1.Wait @@ -84,8 +81,6 @@ func CalculateCPUUsage(c1, c2 *CPUStats) *CPUUsage { } } -// codebeat:enable[CYCLO] - // GetCPUStats returns basic CPU stats func GetCPUStats() (*CPUStats, error) { s, closer, err := getFileScanner(procStatFile) @@ -148,8 +143,6 @@ func GetCPUCount() (CPUCount, error) { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC,CYCLO] - // parseCPUStats parses cpu stats data func parseCPUStats(s *bufio.Scanner) (*CPUStats, error) { var err error @@ -288,8 +281,6 @@ func parseCPUInfo(s *bufio.Scanner) ([]*CPUInfo, error) { return info, nil } -// codebeat:enable[LOC,ABC,CYCLO] - // parseCPUCountInfo parses CPU count data func parseCPUCountInfo(data string) uint32 { startNum := strings.Trim(strutil.ReadField(data, 0, false, '-'), "\n\r") diff --git a/system/info_fs_linux.go b/system/info_fs_linux.go index 5eadc638..5431f261 100644 --- a/system/info_fs_linux.go +++ b/system/info_fs_linux.go @@ -105,8 +105,6 @@ func CalculateIOUtil(io1, io2 map[string]*IOStats, duration time.Duration) map[s // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC,CYCLO] - // parseIOStats parses IO stats data func parseIOStats(s *bufio.Scanner) (map[string]*IOStats, error) { var err error @@ -249,8 +247,6 @@ func parseFSInfo(s *bufio.Scanner, calculateStats bool) (map[string]*FSUsage, er return info, nil } -// enable:disable[LOC,ABC,CYCLO] - // getHZ returns number of processor clock ticks per second func getHZ() float64 { // CLK_TCK is a constant on Linux diff --git a/system/info_loadavg_linux.go b/system/info_loadavg_linux.go index 4976e37e..5583a860 100644 --- a/system/info_loadavg_linux.go +++ b/system/info_loadavg_linux.go @@ -46,8 +46,6 @@ func GetLA() (*LoadAvg, error) { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // parseLAInfo parses loadavg data func parseLAInfo(text string) (*LoadAvg, error) { var err error @@ -97,5 +95,3 @@ func parseLAInfo(text string) (*LoadAvg, error) { return la, nil } - -// codebeat:enable[LOC,ABC] diff --git a/system/info_memory_linux.go b/system/info_memory_linux.go index b2594225..96dbe0e9 100644 --- a/system/info_memory_linux.go +++ b/system/info_memory_linux.go @@ -36,8 +36,6 @@ func GetMemUsage() (*MemUsage, error) { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // parseMemUsage parses memory usage info func parseMemUsage(s *bufio.Scanner) (*MemUsage, error) { var err error @@ -91,5 +89,3 @@ func parseMemUsage(s *bufio.Scanner) (*MemUsage, error) { return mem, nil } - -// codebeat:enable[LOC,ABC] diff --git a/system/info_net_linux.go b/system/info_net_linux.go index 632fe8ca..a8d6802c 100644 --- a/system/info_net_linux.go +++ b/system/info_net_linux.go @@ -80,8 +80,6 @@ func CalculateNetworkSpeed(ii1, ii2 map[string]*InterfaceStats, duration time.Du // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // parseInterfacesStats parses interfaces stats data func parseInterfacesStats(s *bufio.Scanner) (map[string]*InterfaceStats, error) { var err error @@ -133,8 +131,6 @@ func parseInterfacesStats(s *bufio.Scanner) (map[string]*InterfaceStats, error) return stats, nil } -// codebeat:enable[LOC,ABC] - // getActiveInterfacesBytes calculate received and transmitted bytes on all interfaces func getActiveInterfacesBytes(is map[string]*InterfaceStats) (uint64, uint64) { var ( diff --git a/system/process/process_cpu.go b/system/process/process_cpu.go index 18ab05ab..3ac31ea2 100644 --- a/system/process/process_cpu.go +++ b/system/process/process_cpu.go @@ -88,8 +88,6 @@ func GetInfo(pid int) (*ProcInfo, error) { return parseStatData(text) } -// codebeat:disable[LOC,ABC] - // GetSample returns ProcSample for CPU usage calculation func GetSample(pid int) (ProcSample, error) { fd, err := os.OpenFile(procFS+"/"+strconv.Itoa(pid)+"/stat", os.O_RDONLY, 0) @@ -110,8 +108,6 @@ func GetSample(pid int) (ProcSample, error) { return parseSampleData(text) } -// codebeat:enable[LOC,ABC] - // CalculateCPUUsage calculates CPU usage func CalculateCPUUsage(s1, s2 ProcSample, duration time.Duration) float64 { total := float64(s2 - s1) @@ -122,8 +118,6 @@ func CalculateCPUUsage(s1, s2 ProcSample, duration time.Duration) float64 { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // parseStatData parses CPU stats data func parseStatData(text string) (*ProcInfo, error) { var err error @@ -197,8 +191,6 @@ func parseSampleData(text string) (ProcSample, error) { return ProcSample(utime + stime + cutime + cstime), nil } -// codebeat:enable[LOC,ABC] - // parseIntField parses int value of field func parseIntField(s string, field int) (int, error) { v, err := strconv.Atoi(s) diff --git a/system/process/process_memory.go b/system/process/process_memory.go index 02a9b1e5..7284a03a 100644 --- a/system/process/process_memory.go +++ b/system/process/process_memory.go @@ -39,8 +39,6 @@ type MemInfo struct { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // GetMemInfo returns info about process memory usage func GetMemInfo(pid int) (*MemInfo, error) { fd, err := os.OpenFile(procFS+"/"+strconv.Itoa(pid)+"/status", os.O_RDONLY, 0) @@ -102,8 +100,6 @@ func GetMemInfo(pid int) (*MemInfo, error) { return info, nil } -// codebeat:enable[LOC,ABC] - // ////////////////////////////////////////////////////////////////////////////////// // // parseSize parse size in kB diff --git a/system/process/process_mount.go b/system/process/process_mount.go index 38dac93e..ac18b10e 100644 --- a/system/process/process_mount.go +++ b/system/process/process_mount.go @@ -40,8 +40,6 @@ type MountInfo struct { // ////////////////////////////////////////////////////////////////////////////////// // -// codebeat:disable[LOC,ABC] - // GetMountInfo returns info about process mounts func GetMountInfo(pid int) ([]*MountInfo, error) { fd, err := os.OpenFile(procFS+"/"+strconv.Itoa(pid)+"/mountinfo", os.O_RDONLY, 0) @@ -127,8 +125,6 @@ func parseMountInfoLine(data string) (*MountInfo, error) { return info, nil } -// codebeat:enable[LOC,ABC] - // parseStDevValue parses st_dev major and minor values func parseStDevValue(data string) (uint16, uint16, error) { major, err := parseFieldUint16(strutil.ReadField(data, 0, false, ':'), "StDevMajor") diff --git a/timeutil/timeutil.go b/timeutil/timeutil.go index 029ed679..16240ebc 100644 --- a/timeutil/timeutil.go +++ b/timeutil/timeutil.go @@ -397,9 +397,6 @@ func FromISOWeek(week, year int, loc *time.Location) time.Time { // ////////////////////////////////////////////////////////////////////////////////// // -// It's ok to have so long method here -// codebeat:disable[LOC,ABC] - func convertDuration(d any) (time.Duration, bool) { switch u := d.(type) { case time.Duration: @@ -531,8 +528,6 @@ func replaceDateTag(d time.Time, input, output *bytes.Buffer) { } } -// codebeat:enable[LOC,ABC] - func getShortWeekday(d time.Weekday) string { long := getLongWeekday(d) @@ -706,9 +701,6 @@ func getShortDuration(dur time.Duration, highPrecision bool) string { return fmt.Sprintf("%d:%02d", m, d) } -// It's ok to have so nested blocks in this method -// codebeat:disable[BLOCK_NESTING] - func getPrettyLongDuration(dur time.Duration) string { d := int64(dur.Seconds()) @@ -767,8 +759,6 @@ func getPrettySimpleDuration(dur time.Duration) string { return "< 1 second" } -// codebeat:enable[BLOCK_NESTING] - func getPrettyShortDuration(d time.Duration, separator string) string { switch { case d >= 24*time.Hour: