Function list_remove
has 5 return statements (exceeds 4 allowed). Open
func list_remove(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) != 1 {
return nil, fmt.Errorf("remove: got %d arguments, want 1", len(args))
}
if err := g.checkMutable("remove from"); err != nil {
Function list_pop
has 5 return statements (exceeds 4 allowed). Open
func list_pop(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
index := g.v.Len() - 1
switch len(args) {
case 0:
// ok
Function list_extend
has 5 return statements (exceeds 4 allowed). Open
func list_extend(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) != 1 {
return nil, fmt.Errorf("extend: got %d arguments, want 1", len(args))
}
if err := g.checkMutable("extend"); err != nil {
Function list_insert
has 5 return statements (exceeds 4 allowed). Open
func list_insert(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
if len(args) != 2 {
return nil, fmt.Errorf("extend: got %d arguments, want 2", len(args))
}
if err := g.checkMutable("insert into"); err != nil {
Similar blocks of code found in 2 locations. Consider refactoring. Open
func sliceAttr(g *GoSlice, name string, methods map[string]builtinSliceMethod) (starlark.Value, error) {
method := methods[name]
if method == nil {
return nil, nil // no such method
}
- 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 173.
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
exported method GoSlice.Len should have comment or be unexported Open
func (g *GoSlice) Len() int {
- Exclude checks
don't use underscores in Go names; func list_pop should be listPop Open
func list_pop(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
- Exclude checks
don't use underscores in Go names; func list_extend should be listExtend Open
func list_extend(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
- Exclude checks
don't use underscores in Go names; func list_index should be listIndex Open
func list_index(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
- Exclude checks
exported method GoSlice.Slice should have comment or be unexported Open
func (g *GoSlice) Slice(start, end, step int) starlark.Value {
- Exclude checks
don't use underscores in Go names; func parameter start_ should be start Open
func indices(start_, end_ starlark.Value, len int) (start, end int, err error) {
- Exclude checks
don't use underscores in Go names; func list_remove should be listRemove Open
func list_remove(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
- Exclude checks
don't use underscores in Go names; var end_ should be end Open
var start_, end_ starlark.Value
- Exclude checks
exported method GoSlice.SetIndex should have comment or be unexported Open
func (g *GoSlice) SetIndex(index int, v starlark.Value) error {
- Exclude checks
don't use underscores in Go names; func list_append should be listAppend Open
func list_append(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
- Exclude checks
exported method GoSlice.Clear should have comment or be unexported Open
func (g *GoSlice) Clear() error {
- Exclude checks
don't use underscores in Go names; func parameter end_ should be end Open
func indices(start_, end_ starlark.Value, len int) (start, end int, err error) {
- Exclude checks
don't use underscores in Go names; func list_insert should be listInsert Open
func list_insert(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
- Exclude checks
don't use underscores in Go names; var start_ should be start Open
var start_, end_ starlark.Value
- Exclude checks
exported method GoSlice.Attr should have comment or be unexported Open
func (g *GoSlice) Attr(name string) (starlark.Value, error) {
- Exclude checks
exported method GoSlice.AttrNames should have comment or be unexported Open
func (g *GoSlice) AttrNames() []string {
- Exclude checks
don't use underscores in Go names; func list_clear should be listClear Open
func list_clear(fnname string, g *GoSlice, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) {
- Exclude checks
exported method GoSlice.Iterate should have comment or be unexported Open
func (g *GoSlice) Iterate() starlark.Iterator {
- Exclude checks