Showing 16 of 16 total issues
Function TableView
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func TableView(
cmd *cobra.Command,
heats contribution.HeatMap,
scope xtime.Range,
opts ...func(time.Time, string) string,
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (r *packer) Unpack(file Input, ptr any) error {
ext := strings.ToLower(filepath.Ext(file.Name()))
r.guard.RLock()
decoder, has := r.decoders[ext]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 137.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (r *packer) Pack(file Output, data any) error {
ext := strings.ToLower(filepath.Ext(file.Name()))
r.guard.RLock()
encoder, has := r.encoders[ext]
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 137.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function Suggest
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Suggest(cmd *cobra.Command, cnf *config.Tool) *cobra.Command {
var (
delta bool
short bool
target uint
Function Suggest
has 8 return statements (exceeds 4 allowed). Open
func Suggest(cmd *cobra.Command, cnf *config.Tool) *cobra.Command {
var (
delta bool
short bool
target uint
Function Diff
has 7 return statements (exceeds 4 allowed). Open
func Diff(cmd *cobra.Command, cnf *config.Tool) *cobra.Command {
cmd.Args = cobra.ExactArgs(2)
isYear := regexp.MustCompile(`^\d{4}$`)
wrap := func(err error, arg string) error {
Function New
has 6 return statements (exceeds 4 allowed). Open
func New(cnf *config.Tool) *cobra.Command {
command := cobra.Command{
Args: cobra.NoArgs,
Use: "hub",
Short: "fetch data from GitHub and Trello to manage it",
Function Everyday
has 6 return statements (exceeds 4 allowed). Open
func Everyday(intervals ...Interval) Schedule {
assert.True(func() bool { return len(intervals) > 0 })
sort.Slice(intervals, func(i, j int) bool {
assert.True(func() bool { return intervals[i].isValid() })
assert.True(func() bool { return intervals[j].isValid() })
Function Suggest
has 6 return statements (exceeds 4 allowed). Open
func Suggest(
heats HeatMap,
scope xtime.Range,
hours xtime.Schedule,
basis uint,
Function NewVanityCommand
has 5 return statements (exceeds 4 allowed). Open
func NewVanityCommand() *cobra.Command {
command := cobra.Command{
Args: cobra.NoArgs,
Use: "vanity",
Short: "vanity URL manager",
Method Schedule.Suggest
has 5 return statements (exceeds 4 allowed). Open
func (s Schedule) Suggest(t time.Time) time.Time {
if len(s) == 0 || len(s[t.Weekday()]) == 0 {
return time.Time{}
}
Method Makefile.AppendTo
has 5 return statements (exceeds 4 allowed). Open
func (makefile Makefile) AppendTo(output io.Writer) error {
file, err := os.Open(makefile.Name())
if err != nil {
return err
}
Function Histogram
has 5 return statements (exceeds 4 allowed). Open
func Histogram(cmd *cobra.Command, cnf *config.Tool) *cobra.Command {
var (
zero bool
)
cmd.Args = cobra.MaximumNArgs(1)
Function Snapshot
has 5 return statements (exceeds 4 allowed). Open
func Snapshot(cmd *cobra.Command, cnf *config.Tool) *cobra.Command {
cmd.Args = cobra.MaximumNArgs(1)
cmd.RunE = func(cmd *cobra.Command, args []string) error {
// dependencies and defaults
Function FallbackDate
has 5 return statements (exceeds 4 allowed). Open
func FallbackDate(args []string) time.Time {
fallback := time.Now()
if len(args) > 0 {
raw := strings.Split(args[0], "/")
rawDate := raw[0]
Function New
has 5 return statements (exceeds 4 allowed). Open
func New(cnf *config.Tool) *cobra.Command {
command := cobra.Command{
Args: cobra.NoArgs,
Use: "github",
Short: "GitHub manager",