vorteil/direktiv

View on GitHub
pkg/api/plattformlogs.go

Summary

Maintainability
C
1 day
Test Coverage

Method logController.mountRouter has 72 lines of code (exceeds 50 allowed). Consider refactoring.
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)
Severity: Minor
Found in pkg/api/plattformlogs.go - About 1 hr to fix

    Method logController.stream has 60 lines of code (exceeds 50 allowed). Consider refactoring.
    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)
    
    
    Severity: Minor
    Found in pkg/api/plattformlogs.go - About 1 hr to fix

      Method logController.getNewer has 8 return statements (exceeds 4 allowed).
      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
      Severity: Major
      Found in pkg/api/plattformlogs.go - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

            } else if p, ok := params["trace"]; ok {
                return "flow.trace" + p, nil
            }
        Severity: Major
        Found in pkg/api/plattformlogs.go - About 45 mins to fix

          Method logController.mountRouter has 7 return statements (exceeds 4 allowed).
          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)
          Severity: Major
          Found in pkg/api/plattformlogs.go - About 45 mins to fix

            Method logController.stream has 6 return statements (exceeds 4 allowed).
            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)
            
            
            Severity: Major
            Found in pkg/api/plattformlogs.go - About 40 mins to fix

              Function determineTrack has 6 return statements (exceeds 4 allowed).
              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
              Severity: Major
              Found in pkg/api/plattformlogs.go - About 40 mins to fix

                Method logController.stream has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                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)
                
                
                Severity: Minor
                Found in pkg/api/plattformlogs.go - About 35 mins to fix

                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

                func (m *logController) mountRouter(r chi.Router) {
                    r.Get("/subscribe", m.stream)
                
                    r.Get("/", func(w http.ResponseWriter, r *http.Request) {
                        params := extractLogRequestParams(r)
                Severity: Minor
                Found in pkg/api/plattformlogs.go - About 35 mins to fix

                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

                There are no issues that match your filters.

                Category
                Status