waku-org/go-waku

View on GitHub
tests/utils.go

Summary

Maintainability
C
1 day
Test Coverage
C
70%

Function NewLocalnode has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

func NewLocalnode(priv *ecdsa.PrivateKey, ipAddr *net.TCPAddr, udpPort int, wakuFlags wenr.WakuEnrBitfield, advertiseAddr *net.IP, log *zap.Logger) (*enode.LocalNode, error) {
Severity: Minor
Found in tests/utils.go - About 45 mins to fix

    Function WaitForTimeout has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func WaitForTimeout(t *testing.T, ctx context.Context, timeout time.Duration, wg *sync.WaitGroup, ch chan *protocol.Envelope) {
    Severity: Minor
    Found in tests/utils.go - About 35 mins to fix

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

      func MakeHost(ctx context.Context, port int, randomness io.Reader) (host.Host, error) {
          // Creates a new RSA key pair for this host.
          prvKey, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, randomness)
          if err != nil {
              log.Error(err.Error())
      Severity: Major
      Found in tests/utils.go - About 35 mins to fix

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

        func GenerateRandomSQLInsert(maxLength int) (string, error) {
            // Random table name
            tableName, err := GenerateRandomASCIIString(10)
            if err != nil {
                return "", err
        Severity: Major
        Found in tests/utils.go - About 35 mins to fix

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

          func FindFreePort(t *testing.T, host string, maxAttempts int) (int, error) {
              t.Helper()
          
              if host == "" {
                  host = "localhost"
          Severity: Major
          Found in tests/utils.go and 1 other location - About 2 hrs to fix
          tests/utils.go on lines 99..126

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

          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 FindFreeUDPPort(t *testing.T, host string, maxAttempts int) (int, error) {
              t.Helper()
          
              if host == "" {
                  host = "localhost"
          Severity: Major
          Found in tests/utils.go and 1 other location - About 2 hrs to fix
          tests/utils.go on lines 69..96

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

          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