netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/modules/weblog/charts.go

Summary

Maintainability
F
4 days
Test Coverage

File charts.go has 814 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// SPDX-License-Identifier: GPL-3.0-or-later

package weblog

import (
Severity: Major
Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 1 day to fix

    Method WebLog.createCharts has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
    Open

    func (w *WebLog) createCharts(line *logLine) error {
        if line.empty() {
            return errors.New("empty line")
        }
        w.charts = nil
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 5 hrs 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 WebLog.createCharts has 82 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (w *WebLog) createCharts(line *logLine) error {
        if line.empty() {
            return errors.New("empty line")
        }
        w.charts = nil
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 2 hrs to fix

      Method WebLog.createCharts has 16 return statements (exceeds 4 allowed).
      Open

      func (w *WebLog) createCharts(line *logLine) error {
          if line.empty() {
              return errors.New("empty line")
          }
          w.charts = nil
      Severity: Major
      Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 1 hr to fix

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

        func addURLCharts(charts *Charts, patterns []userPattern) error {
            if len(patterns) == 0 {
                return nil
            }
            chart, err := newURLPatternChart(patterns)
        Severity: Major
        Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 35 mins to fix

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

          func addRespCodesCharts(charts *Charts, group bool) error {
              if err := charts.Add(reqTypes.Copy()); err != nil {
                  return err
              }
              if err := charts.Add(respCodeClass.Copy()); err != nil {
          Severity: Major
          Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 35 mins to fix

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

            func newCustomTimeFieldCharts(fields []customTimeField) (Charts, error) {
                charts := Charts{}
                for i, f := range fields {
                    chartTime, err := newCustomTimeFieldChart(f)
                    if err != nil {
            Severity: Major
            Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 35 mins to fix

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

              func addReqProcTimeCharts(charts *Charts, histogram []float64, patterns []userPattern) error {
                  if err := charts.Add(reqProcTime.Copy()); err != nil {
                      return err
                  }
                  for _, p := range patterns {
              Severity: Major
              Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go - About 35 mins to fix

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

                func newUpsRespTimeHistChart(histogram []float64) (*Chart, error) {
                    chart := upsRespTimeHist.Copy()
                    for i, v := range histogram {
                        dim := &Dim{
                            ID:   fmt.Sprintf("upstream_resp_time_hist_bucket_%d", i+1),
                Severity: Major
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 1 other location - About 1 hr to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 458..478

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

                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 newReqProcTimeHistChart(histogram []float64) (*Chart, error) {
                    chart := reqProcTimeHist.Copy()
                    for i, v := range histogram {
                        dim := &Dim{
                            ID:   fmt.Sprintf("req_proc_time_hist_bucket_%d", i+1),
                Severity: Major
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 1 other location - About 1 hr to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 480..500

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

                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 3 locations. Consider refactoring.
                Open

                var (
                    reqProcTime = Chart{
                        ID:       "request_processing_time",
                        Title:    "Request Processing Time",
                        Units:    "milliseconds",
                Severity: Major
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 2 other locations - About 1 hr to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 222..244
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 370..392

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

                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 3 locations. Consider refactoring.
                Open

                var (
                    upsRespTime = Chart{
                        ID:       "upstream_response_time",
                        Title:    "Upstream Response Time",
                        Units:    "milliseconds",
                Severity: Major
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 2 other locations - About 1 hr to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 197..219
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 370..392

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

                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 3 locations. Consider refactoring.
                Open

                var (
                    reqByCustomTimeField = Chart{
                        ID:       "custom_time_field_%s_summary",
                        Title:    `Custom Time Field "%s" Summary`,
                        Units:    "milliseconds",
                Severity: Major
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 2 other locations - About 1 hr to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 197..219
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 222..244

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

                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

                    reqTypes = Chart{
                        ID:       "requests_by_type",
                        Title:    "Requests By Type",
                        Units:    "requests/s",
                        Fam:      "requests",
                Severity: Major
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 1 other location - About 1 hr to fix
                src/go/collectors/go.d.plugin/modules/squidlog/charts.go on lines 71..85

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

                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 newURLPatternBandwidthChart(name string) *Chart {
                    chart := urlPatternBandwidth.Copy()
                    chart.ID = fmt.Sprintf(chart.ID, name)
                    chart.Fam = fmt.Sprintf(chart.Fam, name)
                    for _, d := range chart.Dims {
                Severity: Minor
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 1 other location - About 50 mins to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 541..549

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

                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 newURLPatternReqProcTimeChart(name string) *Chart {
                    chart := urlPatternReqProcTime.Copy()
                    chart.ID = fmt.Sprintf(chart.ID, name)
                    chart.Fam = fmt.Sprintf(chart.Fam, name)
                    for _, d := range chart.Dims {
                Severity: Minor
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 1 other location - About 50 mins to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 531..539

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

                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 addBandwidthCharts(charts *Charts, patterns []userPattern) error {
                    if err := charts.Add(bandwidth.Copy()); err != nil {
                        return err
                    }
                
                
                Severity: Minor
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 1 other location - About 45 mins to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 752..764

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

                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 addMethodCharts(charts *Charts, patterns []userPattern) error {
                    if err := charts.Add(reqByMethod.Copy()); err != nil {
                        return err
                    }
                
                
                Severity: Minor
                Found in src/go/collectors/go.d.plugin/modules/weblog/charts.go and 1 other location - About 45 mins to fix
                src/go/collectors/go.d.plugin/modules/weblog/charts.go on lines 809..821

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

                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

                There are no issues that match your filters.

                Category
                Status