RTradeLtd/libp2px-core

View on GitHub

Showing 24 of 24 total issues

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

func (bwc *BandwidthCounter) GetBandwidthByPeer() map[peer.ID]Stats {
    peers := make(map[peer.ID]Stats)

    bwc.peerIn.ForEach(func(p string, meter *flow.Meter) {
        id := peer.ID(p)
Severity: Major
Found in metrics/bandwidth.go and 1 other location - About 2 hrs to fix
metrics/bandwidth.go on lines 131..155

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

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 (bwc *BandwidthCounter) GetBandwidthByProtocol() map[protocol.ID]Stats {
    protocols := make(map[protocol.ID]Stats)

    bwc.protocolIn.ForEach(func(p string, meter *flow.Meter) {
        id := protocol.ID(p)
Severity: Major
Found in metrics/bandwidth.go and 1 other location - About 2 hrs to fix
metrics/bandwidth.go on lines 102..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 245.

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

Function KeyStretcher has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func KeyStretcher(cipherType string, hashType string, secret []byte) (StretchedKeys, StretchedKeys) {
    var cipherKeySize int
    var ivSize int
    switch cipherType {
    case "AES-128":
Severity: Minor
Found in crypto/key.go - About 1 hr to fix

    Method sweeper.update has 53 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (sw *sweeper) update() {
        sw.snapshotMu.Lock()
        defer sw.snapshotMu.Unlock()
    
        now := time.Now()
    Severity: Minor
    Found in metrics/flow/sweeper.go - About 1 hr to fix

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

      func UnmarshalRsaPublicKey(b []byte) (PubKey, error) {
          key, err := unmarshalOpensslPublicKey(b)
          if err != nil {
              return nil, err
          }
      Severity: Minor
      Found in crypto/rsa_openssl.go and 1 other location - About 50 mins to fix
      crypto/rsa_openssl.go on lines 41..53

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

      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 UnmarshalRsaPrivateKey(b []byte) (PrivKey, error) {
          key, err := unmarshalOpensslPrivateKey(b)
          if err != nil {
              return nil, err
          }
      Severity: Minor
      Found in crypto/rsa_openssl.go and 1 other location - About 50 mins to fix
      crypto/rsa_openssl.go on lines 56..68

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

      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

      Method Conn.runHandshakeSync has 7 return statements (exceeds 4 allowed).
      Open

      func (ic *Conn) runHandshakeSync() error {
          // If we were initialized without keys, behave as in plaintext/1.0.0 (do nothing)
          if ic.localPrivKey == nil {
              return nil
          }
      Severity: Major
      Found in sec/insecure/insecure.go - About 45 mins to fix

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

        func (bwc *BandwidthCounter) LogRecvMessageStream(size int64, proto protocol.ID, p peer.ID) {
            bwc.protocolIn.Get(string(proto)).Mark(uint64(size))
            bwc.peerIn.Get(string(p)).Mark(uint64(size))
        }
        Severity: Minor
        Found in metrics/bandwidth.go and 1 other location - About 40 mins to fix
        metrics/bandwidth.go on lines 45..48

        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

        Further Reading

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

        func (bwc *BandwidthCounter) LogSentMessageStream(size int64, proto protocol.ID, p peer.ID) {
            bwc.protocolOut.Get(string(proto)).Mark(uint64(size))
            bwc.peerOut.Get(string(p)).Mark(uint64(size))
        }
        Severity: Minor
        Found in metrics/bandwidth.go and 1 other location - About 40 mins to fix
        metrics/bandwidth.go on lines 52..55

        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

        Further Reading

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

        func (bwc *BandwidthCounter) GetBandwidthForPeer(p peer.ID) (out Stats) {
            inSnap := bwc.peerIn.Get(string(p)).Snapshot()
            outSnap := bwc.peerOut.Get(string(p)).Snapshot()
        
            return Stats{
        Severity: Minor
        Found in metrics/bandwidth.go and 1 other location - About 35 mins to fix
        metrics/bandwidth.go on lines 74..84

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

        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 (bwc *BandwidthCounter) GetBandwidthForProtocol(proto protocol.ID) (out Stats) {
            inSnap := bwc.protocolIn.Get(string(proto)).Snapshot()
            outSnap := bwc.protocolOut.Get(string(proto)).Snapshot()
        
            return Stats{
        Severity: Minor
        Found in metrics/bandwidth.go and 1 other location - About 35 mins to fix
        metrics/bandwidth.go on lines 59..69

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

        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 (pk *RsaPublicKey) Bytes() ([]byte, error) {
            pk.cacheLk.Lock()
            var err error
            if pk.cached == nil {
                pk.cached, err = MarshalPublicKey(pk)
        Severity: Minor
        Found in crypto/rsa_go.go and 1 other location - About 35 mins to fix
        crypto/openssl_common.go on lines 59..67

        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

        func (pk *opensslPublicKey) Bytes() ([]byte, error) {
            pk.cacheLk.Lock()
            var err error
            if pk.cached == nil {
                pk.cached, err = MarshalPublicKey(pk)
        Severity: Minor
        Found in crypto/openssl_common.go and 1 other location - About 35 mins to fix
        crypto/rsa_go.go on lines 60..68

        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

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

        func GenerateEKeyPair(curveName string) ([]byte, GenSharedKey, error) {
            var curve elliptic.Curve
        
            switch curveName {
            case "P-256":
        Severity: Major
        Found in crypto/key.go - About 35 mins to fix

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

          func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) {
              if priv == nil {
                  return nil, nil, ErrNilPrivateKey
              }
          
          
          Severity: Major
          Found in crypto/key_openssl.go - About 35 mins to fix

            2: cannot find package "github.com/RTradeLtd/libp2px-core/host" in any of:
            Open

                "github.com/RTradeLtd/libp2px-core/host"
            Severity: Minor
            Found in alias.go by govet

            Your code does not pass gofmt in 1 place. Go fmt your code!
            Open

            // +build !openssl
            Severity: Minor
            Found in crypto/rsa_go.go by gofmt

            Your code does not pass gofmt in 1 place. Go fmt your code!
            Open

            // +build !openssl
            Severity: Minor
            Found in crypto/key_not_openssl.go by gofmt

            Your code does not pass gofmt in 1 place. Go fmt your code!
            Open

            // Package event contains the abstractions for a local event bus, along with the standard events
            Severity: Minor
            Found in event/doc.go by gofmt

            Your code does not pass gofmt in 1 place. Go fmt your code!
            Open

            package network
            Severity: Minor
            Found in network/conn.go by gofmt
            Severity
            Category
            Status
            Source
            Language