pkg/api/plattformlogs.go
Method logController.mountRouter
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m *logController) mountRouter(r chi.Router) {
r.Get("/subscribe", m.stream)
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
params := extractLogRequestParams(r)
Method logController.stream
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (m logController) stream(w http.ResponseWriter, r *http.Request) {
// cursor is set to multiple seconds before the current time to mitigate data loss
// that may occur due to delays between submitting and processing the request, or when a sequence of client requests is necessary.
cursor := time.Now().UTC().Add(-time.Second * 3)
Method logController.getNewer
has 8 return statements (exceeds 4 allowed). Open
Open
func (m logController) getNewer(ctx context.Context, t time.Time, params map[string]string) ([]logEntry, error) {
var logs []core.LogEntry
var err error
// Determine the track based on the provided parameters
Avoid deeply nested control flow statements. Open
Open
} else if p, ok := params["trace"]; ok {
return "flow.trace" + p, nil
}
Method logController.mountRouter
has 7 return statements (exceeds 4 allowed). Open
Open
func (m *logController) mountRouter(r chi.Router) {
r.Get("/subscribe", m.stream)
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
params := extractLogRequestParams(r)
Method logController.stream
has 6 return statements (exceeds 4 allowed). Open
Open
func (m logController) stream(w http.ResponseWriter, r *http.Request) {
// cursor is set to multiple seconds before the current time to mitigate data loss
// that may occur due to delays between submitting and processing the request, or when a sequence of client requests is necessary.
cursor := time.Now().UTC().Add(-time.Second * 3)
Function determineTrack
has 6 return statements (exceeds 4 allowed). Open
Open
func determineTrack(params map[string]string) (string, error) {
if p, ok := params["instance"]; ok {
return "flow.instance." + "%" + p + "%", nil
} else if p, ok := params["route"]; ok {
return "flow.route." + params["namespace"] + "." + p, nil
Method logController.stream
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (m logController) stream(w http.ResponseWriter, r *http.Request) {
// cursor is set to multiple seconds before the current time to mitigate data loss
// that may occur due to delays between submitting and processing the request, or when a sequence of client requests is necessary.
cursor := time.Now().UTC().Add(-time.Second * 3)
- 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 logController.mountRouter
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func (m *logController) mountRouter(r chi.Router) {
r.Get("/subscribe", m.stream)
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
params := extractLogRequestParams(r)
- 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"