8000 [REFACTOR] Small changes needed to increase code readability and maintainability. · Issue #64 · pesos/grofer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[REFACTOR] Small changes needed to increase code readability and maintainability. #64
Closed
@MadhavJivrajani

Description

@MadhavJivrajani

Small amounts of refactoring can be done to all files under cmd which have additional flags.

Creating const types for default values of flags.

  • Each flag in cobra needs to have a default value set. As of now the default value in some cases is mentioned while creating the flag such as

    procCmd.Flags().Int32P("pid", "p", -1, "specify pid of process")

  • For increased readability and also maintainability, it would be better to have a const of these default values like this:

const (
	DefaultProcRefreshRate = 3000
)

Splitting flag initialization to multiple lines

A flag initialization such as:

procCmd.Flags().Int32P("refresh", "r", DefaultProcRefreshRate, "Process information UI refreshes rate in milliseconds greater than 1000")

could be re-written to:

procCmd.Flags().Int32P(
    "refresh",
    "r",
    DefaultProcRefreshRate,
    "Process information UI refreshes rate in milliseconds greater than 1000",
)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0