Method reader.drainJournal
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (r *reader) drainJournal(ctx context.Context) (bool, error) {
for i := 0; ; i++ {
// Read the entry's timestamp.
timestamp, err := r.j.Realtime()
if err != nil {
- 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
Method reader.readLogs
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r *reader) readLogs(ctx context.Context) {
defer close(r.logWatcher.Msg)
// Make sure the ready channel is closed in the event of an early
// return.
Function waitUntilFlushedImpl
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func waitUntilFlushedImpl(s *journald) error {
if s.readSyncTimeout == 0 {
return nil
}
Function waitUntilFlushedImpl
has 10 return statements (exceeds 4 allowed). Open
func waitUntilFlushedImpl(s *journald) error {
if s.readSyncTimeout == 0 {
return nil
}
Method reader.initialSeekTail
has 8 return statements (exceeds 4 allowed). Open
func (r *reader) initialSeekTail() (bool, error) {
var err error
if r.config.Until.IsZero() {
err = r.j.SeekTail()
} else {
Method reader.readLogs
has 8 return statements (exceeds 4 allowed). Open
func (r *reader) readLogs(ctx context.Context) {
defer close(r.logWatcher.Msg)
// Make sure the ready channel is closed in the event of an early
// return.
Method reader.wait
has 7 return statements (exceeds 4 allowed). Open
func (r *reader) wait(ctx context.Context) (bool, error) {
deadline := r.drainDeadline
if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
deadline = d
}
Method reader.drainJournal
has 7 return statements (exceeds 4 allowed). Open
func (r *reader) drainJournal(ctx context.Context) (bool, error) {
for i := 0; ; i++ {
// Read the entry's timestamp.
timestamp, err := r.j.Realtime()
if err != nil {
Method reader.readJournal
has 6 return statements (exceeds 4 allowed). Open
func (r *reader) readJournal(ctx context.Context) error {
caughtUp := r.s.ordinal.Load()
if more, err := r.drainJournal(ctx); err != nil || !more {
return err
}
Method reader.wait
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (r *reader) wait(ctx context.Context) (bool, error) {
deadline := r.drainDeadline
if d, ok := ctx.Deadline(); ok && d.Before(deadline) {
deadline = d
}
- 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 waitUntilFlushedImpl
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func waitUntilFlushedImpl(s *journald) error {
if s.readSyncTimeout == 0 {
return nil
}
- 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
Method reader.readLogs
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func (r *reader) readLogs(ctx context.Context) {
defer close(r.logWatcher.Msg)
// Make sure the ready channel is closed in the event of an early
// return.
- 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"