hussar-lang/hussar

View on GitHub
object/object.go

Summary

Maintainability
A
1 hr
Test Coverage

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (a *Array) Inspect() string {
    var out bytes.Buffer

    elements := []string{}
    for _, e := range a.Elements {
Severity: Minor
Found in object/object.go and 1 other location - About 1 hr to fix
ast/ast.go on lines 331..344

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 129.

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

Further Reading

exported const ERROR_OBJ should have comment (or a comment on this block) or be unexported
Open

    ERROR_OBJ        = "ERROR"
Severity: Minor
Found in object/object.go by golint

exported method Boolean.Inspect should have comment or be unexported
Open

func (b *Boolean) Inspect() string  { return fmt.Sprintf("%t", b.Value) }
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    BOOLEAN_OBJ      = "BOOLEAN"
Severity: Minor
Found in object/object.go by golint

comment on exported type Integer should be of the form "Integer ..." (with optional leading article)
Open

// === Integer ===
Severity: Minor
Found in object/object.go by golint

exported method ReturnValue.Inspect should have comment or be unexported
Open

func (rv *ReturnValue) Inspect() string  { return rv.Value.Inspect() }
Severity: Minor
Found in object/object.go by golint

comment on exported type Exit should be of the form "Exit ..." (with optional leading article)
Open

// === Exit ===
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    INTEGER_OBJ      = "INTEGER"
Severity: Minor
Found in object/object.go by golint

exported method Exit.Inspect should have comment or be unexported
Open

func (e *Exit) Inspect() string {
Severity: Minor
Found in object/object.go by golint

exported method Error.Type should have comment or be unexported
Open

func (e *Error) Type() ObjectType { return ERROR_OBJ }
Severity: Minor
Found in object/object.go by golint

exported method String.Type should have comment or be unexported
Open

func (s *String) Type() ObjectType { return STRING_OBJ }
Severity: Minor
Found in object/object.go by golint

exported method Null.Inspect should have comment or be unexported
Open

func (n *Null) Inspect() string  { return "null" }
Severity: Minor
Found in object/object.go by golint

type name will be used as object.ObjectType by other packages, and that stutters; consider calling this Type
Open

type ObjectType string
Severity: Minor
Found in object/object.go by golint

comment on exported type String should be of the form "String ..." (with optional leading article)
Open

// === String ===
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    BUILTIN_OBJ      = "BUILTIN"
Severity: Minor
Found in object/object.go by golint

exported method Error.Inspect should have comment or be unexported
Open

func (e *Error) Inspect() string {
Severity: Minor
Found in object/object.go by golint

comment on exported type Null should be of the form "Null ..." (with optional leading article)
Open

// === Null ===
Severity: Minor
Found in object/object.go by golint

comment on exported type ReturnValue should be of the form "ReturnValue ..." (with optional leading article)
Open

// === Return ===
Severity: Minor
Found in object/object.go by golint

exported method Builtin.Inspect should have comment or be unexported
Open

func (b *Builtin) Inspect() string  { return "builtin function" }
Severity: Minor
Found in object/object.go by golint

comment on exported type Error should be of the form "Error ..." (with optional leading article)
Open

// === Errors ===
Severity: Minor
Found in object/object.go by golint

exported method Integer.Inspect should have comment or be unexported
Open

func (i *Integer) Inspect() string  { return fmt.Sprintf("%d", i.Value) }
Severity: Minor
Found in object/object.go by golint

exported method Boolean.Type should have comment or be unexported
Open

func (b *Boolean) Type() ObjectType { return BOOLEAN_OBJ }
Severity: Minor
Found in object/object.go by golint

exported method Function.Inspect should have comment or be unexported
Open

func (f *Function) Inspect() string {
Severity: Minor
Found in object/object.go by golint

comment on exported type BuiltinFunction should be of the form "BuiltinFunction ..." (with optional leading article)
Open

// === Builtin ===
Severity: Minor
Found in object/object.go by golint

exported method Exit.Type should have comment or be unexported
Open

func (e *Exit) Type() ObjectType { return EXIT_OBJ }
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    ERROR_OBJ        = "ERROR"
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    NULL_OBJ         = "NULL"
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    RETURN_VALUE_OBJ = "RETURN_VALUE"
Severity: Minor
Found in object/object.go by golint

exported method Builtin.Type should have comment or be unexported
Open

func (b *Builtin) Type() ObjectType { return BUILTIN_OBJ }
Severity: Minor
Found in object/object.go by golint

exported method Null.Type should have comment or be unexported
Open

func (n *Null) Type() ObjectType { return NULL_OBJ }
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    ARRAY_OBJ        = "ARRAY"
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    EXIT_OBJ         = "EXIT"
Severity: Minor
Found in object/object.go by golint

exported type Object should have comment or be unexported
Open

type Object interface {
Severity: Minor
Found in object/object.go by golint

exported method String.Inspect should have comment or be unexported
Open

func (s *String) Inspect() string  { return s.Value }
Severity: Minor
Found in object/object.go by golint

exported method Function.Type should have comment or be unexported
Open

func (f *Function) Type() ObjectType { return FUNCTION_OBJ }
Severity: Minor
Found in object/object.go by golint

comment on exported type Array should be of the form "Array ..." (with optional leading article)
Open

// === Array ===
Severity: Minor
Found in object/object.go by golint

exported method Array.Inspect should have comment or be unexported
Open

func (a *Array) Inspect() string {
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    FUNCTION_OBJ     = "FUNCTION"
Severity: Minor
Found in object/object.go by golint

comment on exported type Boolean should be of the form "Boolean ..." (with optional leading article)
Open

// === Boolean ===
Severity: Minor
Found in object/object.go by golint

exported method Array.Type should have comment or be unexported
Open

func (a *Array) Type() ObjectType { return ARRAY_OBJ }
Severity: Minor
Found in object/object.go by golint

exported method Integer.Type should have comment or be unexported
Open

func (i *Integer) Type() ObjectType { return INTEGER_OBJ }
Severity: Minor
Found in object/object.go by golint

exported type ObjectType should have comment or be unexported
Open

type ObjectType string
Severity: Minor
Found in object/object.go by golint

exported method ReturnValue.Type should have comment or be unexported
Open

func (rv *ReturnValue) Type() ObjectType { return RETURN_VALUE_OBJ }
Severity: Minor
Found in object/object.go by golint

exported type Builtin should have comment or be unexported
Open

type Builtin struct {
Severity: Minor
Found in object/object.go by golint

don't use ALL_CAPS in Go names; use CamelCase
Open

    STRING_OBJ       = "STRING"
Severity: Minor
Found in object/object.go by golint

comment on exported type Function should be of the form "Function ..." (with optional leading article)
Open

// === Function ===
Severity: Minor
Found in object/object.go by golint

There are no issues that match your filters.

Category
Status