meta/stub/stub.go

Summary

Maintainability
F
3 days
Test Coverage
C
70%

File stub.go has 731 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package stub

import (
    "fmt"
    "io"
Severity: Minor
Found in meta/stub/stub.go - About 7 hrs to fix

    Function generateObjectInterface has 89 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func generateObjectInterface(file *jen.File, set *signature.TypeSet,
        itf *idl.InterfaceType) error {
    
        // Proxy and stub shall generate the name method name: reuse
        // the MetaObject method ForEachMethodAndSignal to get an
    Severity: Major
    Found in meta/stub/stub.go - About 2 hrs to fix

      Function generateStubMetaObject has 68 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func generateStubMetaObject(file *jen.File, itf *idl.InterfaceType) error {
          metaMethods := func(d jen.Dict) {
              for _, method := range itf.Methods {
                  d[jen.Lit(int(method.ID))] = jen.Values(jen.Dict{
                      jen.Id("Uid"): jen.Lit(int(method.ID)),
      Severity: Minor
      Found in meta/stub/stub.go - About 1 hr to fix

        Function generateStubObject has 58 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func generateStubObject(file *jen.File, itf *idl.InterfaceType) error {
            writing := make([]jen.Code, 0)
            if itf.Name == "Object" {
                code := jen.Id(`p.signal.Activate(activation)`)
                writing = append(writing, code)
        Severity: Minor
        Found in meta/stub/stub.go - About 1 hr to fix

          Function generateReceiveMethod has 55 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func generateReceiveMethod(file *jen.File, itf *idl.InterfaceType) error {
              writing := make([]jen.Code, 0)
          
              prelude := jen.Comment("action dispatch")
              if itf.Name == "Object" {
          Severity: Minor
          Found in meta/stub/stub.go - About 1 hr to fix

            Function methodBodyBlock has 52 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func methodBodyBlock(itf *idl.InterfaceType, method idl.Method,
                methodName string) (*jen.Statement, error) {
            
                writing := make([]jen.Code, 0)
                params := make([]jen.Code, 0)
            Severity: Minor
            Found in meta/stub/stub.go - About 1 hr to fix

              Function generateStubPropertyCallback has 52 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func generateStubPropertyCallback(file *jen.File, itf *idl.InterfaceType) error {
              
                  writing := make([]jen.Code, 0)
              
                  method := func(m object.MetaMethod, methodName string) error {
              Severity: Minor
              Found in meta/stub/stub.go - About 1 hr to fix

                Function generateObjectInterface has 8 return statements (exceeds 4 allowed).
                Open

                func generateObjectInterface(file *jen.File, set *signature.TypeSet,
                    itf *idl.InterfaceType) error {
                
                    // Proxy and stub shall generate the name method name: reuse
                    // the MetaObject method ForEachMethodAndSignal to get an
                Severity: Major
                Found in meta/stub/stub.go - About 50 mins to fix

                  Function generateStubMethods has 8 return statements (exceeds 4 allowed).
                  Open

                  func generateStubMethods(file *jen.File, itf *idl.InterfaceType) error {
                  
                      method := func(m object.MetaMethod, methodName string) error {
                          method := itf.Methods[m.Uid]
                          err := generateMethodMarshal(file, itf, method, methodName)
                  Severity: Major
                  Found in meta/stub/stub.go - About 50 mins to fix

                    Function generateStub has 6 return statements (exceeds 4 allowed).
                    Open

                    func generateStub(f *jen.File, itf *idl.InterfaceType) error {
                        if err := generateStubType(f, itf); err != nil {
                            return err
                        }
                        if err := generateStubConstructor(f, itf); err != nil {
                    Severity: Major
                    Found in meta/stub/stub.go - About 40 mins to fix

                      Function generateReceiveMethod has 5 return statements (exceeds 4 allowed).
                      Open

                      func generateReceiveMethod(file *jen.File, itf *idl.InterfaceType) error {
                          writing := make([]jen.Code, 0)
                      
                          prelude := jen.Comment("action dispatch")
                          if itf.Name == "Object" {
                      Severity: Major
                      Found in meta/stub/stub.go - About 35 mins to fix

                        Function generateStubPropertyCallback has 5 return statements (exceeds 4 allowed).
                        Open

                        func generateStubPropertyCallback(file *jen.File, itf *idl.InterfaceType) error {
                        
                            writing := make([]jen.Code, 0)
                        
                            method := func(m object.MetaMethod, methodName string) error {
                        Severity: Major
                        Found in meta/stub/stub.go - About 35 mins to fix

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

                          func generateSignalHelper(file *jen.File, itf *idl.InterfaceType,
                              signal idl.Signal, signalName string) error {
                              tuple := signal.Tuple()
                          
                              body, err := signalBodyBlock(itf, signal, signalName)
                          Severity: Major
                          Found in meta/stub/stub.go and 1 other location - About 1 hr to fix
                          meta/stub/stub.go on lines 297..309

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

                          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

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

                          func generatePropertyHelper(file *jen.File, itf *idl.InterfaceType,
                              property idl.Property, propertyName string) error {
                              tuple := property.Tuple()
                          
                              body, err := propertyBodyBlock(itf, property, propertyName)
                          Severity: Major
                          Found in meta/stub/stub.go and 1 other location - About 1 hr to fix
                          meta/stub/stub.go on lines 283..295

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

                          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

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

                              metaSignals := func(d jen.Dict) {
                                  for _, signal := range itf.Signals {
                                      d[jen.Lit(int(signal.ID))] = jen.Values(jen.Dict{
                                          jen.Id("Uid"):  jen.Lit(int(signal.ID)),
                                          jen.Id("Name"): jen.Lit(signal.Name),
                          Severity: Major
                          Found in meta/stub/stub.go and 1 other location - About 1 hr to fix
                          meta/stub/stub.go on lines 377..387

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

                          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

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

                              metaProperties := func(d jen.Dict) {
                                  for _, property := range itf.Properties {
                                      d[jen.Lit(int(property.ID))] = jen.Values(jen.Dict{
                                          jen.Id("Uid"):  jen.Lit(int(property.ID)),
                                          jen.Id("Name"): jen.Lit(property.Name),
                          Severity: Major
                          Found in meta/stub/stub.go and 1 other location - About 1 hr to fix
                          meta/stub/stub.go on lines 366..376

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

                          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

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

                              for _, param := range property.Params {
                                  code = jen.If(jen.Err().Op(":=").Add(
                                      param.Type.Marshal(param.Name, "&buf"),
                                  ).Op(";").Err().Op("!=").Nil()).Block(
                                      jen.Id(`return fmt.Errorf("serialize ` +
                          Severity: Major
                          Found in meta/stub/stub.go and 1 other location - About 1 hr to fix
                          meta/stub/stub.go on lines 256..264

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

                          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

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

                              for _, param := range signal.Params {
                                  code = jen.If(jen.Err().Op(":=").Add(
                                      param.Type.Marshal(param.Name, "&buf"),
                                  ).Op(";").Err().Op("!=").Nil()).Block(
                                      jen.Id(`return fmt.Errorf("serialize ` +
                          Severity: Major
                          Found in meta/stub/stub.go and 1 other location - About 1 hr to fix
                          meta/stub/stub.go on lines 222..230

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

                          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

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

                              property := func(p object.MetaProperty, propertyName string) error {
                                  property := itf.Properties[p.Uid]
                                  propertyName = "Update" + propertyName
                                  err := generatePropertyHelper(file, itf, property,
                                      propertyName)
                          Severity: Minor
                          Found in meta/stub/stub.go and 1 other location - About 35 mins to fix
                          meta/stub/stub.go on lines 322..331

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

                          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

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

                              signal := func(s object.MetaSignal, signalName string) error {
                                  signal := itf.Signals[s.Uid]
                                  signalName = "Signal" + signalName
                                  err := generateSignalHelper(file, itf, signal, signalName)
                                  if err != nil {
                          Severity: Minor
                          Found in meta/stub/stub.go and 1 other location - About 35 mins to fix
                          meta/stub/stub.go on lines 332..342

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

                          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

                          There are no issues that match your filters.

                          Category
                          Status