Showing 615 of 615 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
t.Run("no home_dir parameter", func(t *testing.T) {
p := user.Preparer{UID: &testID, GID: &testID, Username: "test", Name: "test", State: user.StateAbsent}
_, err := p.Prepare(context.Background(), &fr)
assert.NoError(t, err)
- 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 111.
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 (m *mockClient) FindVolume(name string) (*dc.Volume, error) {
args := m.Called(name)
ret := args.Get(0)
if ret == nil {
- 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 111.
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
case groupByName != nil && groupByGid != nil && groupByName.Name != groupByGid.Name || groupByName.Gid != groupByGid.Gid:
status.RaiseLevel(resource.StatusCantChange)
status.Output = append(status.Output, fmt.Sprintf("group add/modify: group %s and gid %s belong to different groups", g.Name, g.GID))
return status, errors.New("cannot add or modify group")
- 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 111.
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
case groupByName != nil && groupByGid != nil && groupByName.Name != groupByGid.Name || groupByName.Gid != groupByGid.Gid:
status.RaiseLevel(resource.StatusCantChange)
status.Output = append(status.Output, fmt.Sprintf("group delete: group %s and gid %s belong to different groups", g.Name, g.GID))
return status, errors.New("cannot delete group")
- 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 111.
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 Parse
has 6 return statements (exceeds 4 allowed). Open
func Parse(content []byte) (resources []*Node, err error) {
obj, err := hcl.ParseBytes(content)
if err != nil {
return resources, err
}
Method Unarchive.isMemAvailable
has 6 return statements (exceeds 4 allowed). Open
func (u *Unarchive) isMemAvailable() (bool, error) {
var (
destStat syscall.Statfs_t
tmpStat syscall.Statfs_t
)
Method grapher.Graph
has 6 return statements (exceeds 4 allowed). Open
func (g *grapher) Graph(in *pb.LoadRequest, stream pb.Grapher_GraphServer) error {
logger, ctx := setIDLogger(stream.Context())
logger = logger.WithField("function", "grapher.Graph")
loaded, err := in.Load(ctx)
Function WithNotify
has 6 return statements (exceeds 4 allowed). Open
func WithNotify(ctx context.Context, in *graph.Graph, notify *graph.Notifier) (*graph.Graph, error) {
var hasErrors error
out, err := in.Transform(ctx,
notify.Transform(func(meta *node.Node, out *graph.Graph) error {
Method User.Check
has 6 return statements (exceeds 4 allowed). Open
func (u *User) Check(context.Context, resource.Renderer) (resource.TaskStatus, error) {
// lookup the user by name
// ErrUnsupported is returned if the system is not supported
// Lookup returns user.UnknownUserError if the user is not found
userByName, nameErr := u.system.Lookup(u.Username)
Function TraverseUntilModule
has 6 return statements (exceeds 4 allowed). Open
func TraverseUntilModule(g *graph.Graph, id string) bool {
if graph.IsRoot(id) {
return true
}
elemMeta, ok := g.Get(id)
Method pipelineGen.PlanNode
has 6 return statements (exceeds 4 allowed). Open
func (g *pipelineGen) PlanNode(ctx context.Context, taski interface{}) (interface{}, error) {
twrapper, ok := taski.(taskWrapper)
if !ok {
asResult, ok := taski.(*Result)
if ok {
Method commandIOContext.exec
has 6 return statements (exceeds 4 allowed). Open
func (c *commandIOContext) exec(script string) (results *CommandResults, err error) {
results = &CommandResults{
Stdin: script,
}
Method Network.Apply
has 6 return statements (exceeds 4 allowed). Open
func (n *Network) Apply(context.Context) (resource.TaskStatus, error) {
status := resource.NewStatus()
var (
nw *dc.Network
Function mergeMaybeUnresolvables
has 6 return statements (exceeds 4 allowed). Open
func mergeMaybeUnresolvables(err1, err2 error) error {
if err1 == nil {
return err2
}
if err2 == nil {
Method CommandResults.Eq
has 6 return statements (exceeds 4 allowed). Open
func (c *CommandResults) Eq(cmd *CommandResults) bool {
if c == nil || cmd == nil {
return false
}
if c.ExitStatus != cmd.ExitStatus {
Method Preparer.convertNumber
has 6 return statements (exceeds 4 allowed). Open
func (p *Preparer) convertNumber(typ reflect.Type, r Renderer, name string, val interface{}, base int) (reflect.Value, error) {
if val == nil {
return reflect.Zero(typ), nil
}
Method Server.newREST
has 6 return statements (exceeds 4 allowed). Open
func (s *Server) newREST(ctx context.Context, addr *url.URL) (*http.Server, error) {
opts, err := s.Security.Client()
if err != nil {
return nil, errors.Wrap(err, "could not generate REST gateway security options")
}
Method Volume.Apply
has 6 return statements (exceeds 4 allowed). Open
func (v *Volume) Apply(context.Context) (resource.TaskStatus, error) {
status := resource.NewStatus()
var (
vol *dc.Volume
Function isExportedField
has 6 return statements (exceeds 4 allowed). Open
func isExportedField(input interface{}, index int) bool {
if nil == input {
return false
}
Method Printer.Show
has 6 return statements (exceeds 4 allowed). Open
func (p Printer) Show(ctx context.Context, g *graph.Graph) (string, error) {
outputBuffer := new(bytes.Buffer)
write := func(s Renderable) { outputBuffer.WriteString(s.String()) }
subgraphs := makeSubgraphMap()