Showing 300 of 401 total issues
Function execute
has 89 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func execute(options Options) {
var err error
hostAddr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("0.0.0.0:%d", options.Port))
if options.NodeKey == nil {
Method Chat.parseInput
has 88 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Chat) parseInput() {
defer c.wg.Done()
for {
select {
case <-c.ctx.Done():
WakuRelay
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type WakuRelay struct {
host host.Host
relayParams *relayParameters
pubsub *pubsub.PubSub
params pubsub.GossipSubParams
Function Test500
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Test500(t *testing.T) {
maxMsgs := 500
maxMsgBytes := int2Bytes(maxMsgs)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
Function getGossipSubParams
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func getGossipSubParams(cfg *GossipSubParams) pubsub.GossipSubParams {
params := pubsub.DefaultGossipSubParams()
if cfg.D != nil {
params.D = *cfg.D
Function getLegacyStoreParams
has 85 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func getLegacyStoreParams(r *http.Request) (*legacy_store.Query, []legacy_store.HistoryRequestOption, error) {
query := &legacy_store.Query{}
var options []legacy_store.HistoryRequestOption
var err error
peerAddrStr := r.URL.Query().Get("peerAddr")
Function NewNode
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
Open
func NewNode(instance *WakuInstance, configJSON string) error {
if err := validateInstance(instance, NotConfigured); err != nil {
return err
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function main
has 81 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func main() {
hostAddr1, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:60000")
hostAddr2, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:60001")
key1, err := randomHex(32)
Function TestPairingObj1Success
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func TestPairingObj1Success(t *testing.T) {
host1, relay1 := createRelayNode(t)
host2, relay2 := createRelayNode(t)
defer host1.Close()
Method WakuFilterLightNode.Unsubscribe
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (wf *WakuFilterLightNode) Unsubscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) (*WakuFilterPushResult, error) {
wf.RLock()
defer wf.RUnlock()
if err := wf.ErrOnNotRunning(); err != nil {
return nil, err
Chat
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *Chat) initReliabilityProtocol() {
c.wg.Add(4)
c.setupMessageRequestHandler()
go c.periodicBufferSweep()
WakuFilterLightNode
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type WakuFilterLightNode struct {
*service.CommonService
h host.Host
broadcaster relay.Broadcaster //TODO: Move the broadcast functionality outside of relay client to a higher SDK layer.
onlineChecker onlinechecker.OnlineChecker
Method WakuFilterLightNode.Subscribe
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (wf *WakuFilterLightNode) Subscribe(ctx context.Context, contentFilter protocol.ContentFilter, opts ...FilterSubscribeOption) ([]*subscription.SubscriptionDetails, error) {
wf.RLock()
defer wf.RUnlock()
if err := wf.ErrOnNotRunning(); err != nil {
return nil, err
Method Pairing.initiatorHandshake
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *Pairing) initiatorHandshake(ctx context.Context, msgCh <-chan *pb.WakuMessage) (doneCh chan error) {
doneCh = make(chan error, 1)
go func() {
defer utils.LogOnPanic()
Method UI.Update
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var (
tiCmd tea.Cmd
vpCmd tea.Cmd
)
Method UI.Update
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
var (
tiCmd tea.Cmd
vpCmd tea.Cmd
)
Method onCreate
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val lbl = findViewById<TextView>(R.id.lbl)
Function Test500
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
Open
func Test500(t *testing.T) {
maxMsgs := 500
maxMsgBytes := int2Bytes(maxMsgs)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function Execute
has 23 return statements (exceeds 4 allowed). Open
Open
func Execute(options NodeOptions) error {
// Set encoding for logs (console, json, ...)
// Note that libp2p reads the encoding from GOLOG_LOG_FMT env var.
lvl, err := zapcore.ParseLevel(options.LogLevel)
if err != nil {
Function execute
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func execute(options Options) {
var err error
hostAddr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("0.0.0.0:%d", options.Port))
if options.NodeKey == nil {