seerline/clchart

View on GitHub
src/chart/cl.chart.scroll.js

Summary

Maintainability
F
3 days
Test Coverage

Function onMouseMove has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  onMouseMove (event) {
    if (!this.mouseDown) return
    const mousePos = event.mousePos
    if (inRect(this.rectMin, mousePos) || inRect(this.rectMax, mousePos)) {
      changeCursorStyle('col-resize')
Severity: Minor
Found in src/chart/cl.chart.scroll.js - About 3 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

Function setPublicRect has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  setPublicRect () { // 计算所有矩形区域
    const count = this.config.range
    let spaceX

    this.rectChart = offsetRect(this.rectMain, this.layout.margin)
Severity: Minor
Found in src/chart/cl.chart.scroll.js - About 1 hr to fix

    Function onMouseMove has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      onMouseMove (event) {
        if (!this.mouseDown) return
        const mousePos = event.mousePos
        if (inRect(this.rectMin, mousePos) || inRect(this.rectMax, mousePos)) {
          changeCursorStyle('col-resize')
    Severity: Minor
    Found in src/chart/cl.chart.scroll.js - About 1 hr to fix

      Function drawButton has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        drawButton () {
          if (this.config.direct === 'horizontal') {
            const spaceY = (this.rectChart.height - this.layout.scroll.height) / 2
            if (this.config.txt.head !== undefined) {
              _drawTxt(this.context, this.rectChart.left + this.scale, this.rectChart.top + spaceY,
      Severity: Minor
      Found in src/chart/cl.chart.scroll.js - About 1 hr to fix

        Function drawButton has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          drawButton () {
            if (this.config.direct === 'horizontal') {
              const spaceY = (this.rectChart.height - this.layout.scroll.height) / 2
              if (this.config.txt.head !== undefined) {
                _drawTxt(this.context, this.rectChart.left + this.scale, this.rectChart.top + spaceY,
        Severity: Minor
        Found in src/chart/cl.chart.scroll.js - About 1 hr 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

        Avoid deeply nested control flow statements.
        Open

                  if (this.who === 'min') {
                    min = this.config.select.max
                    max = curIndex
                    this.who = 'max'
                  } else if (this.who === 'max') {
        Severity: Major
        Found in src/chart/cl.chart.scroll.js - About 45 mins to fix

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

                if (this.config.txt.right !== undefined && this.rectMid.width > 2 * len) {
                  _drawTxt(this.context, this.rectMid.left + this.rectMid.width - this.scale,
                    this.rectMid.top + spaceY, this.config.txt.right,
                    this.layout.scroll.font, this.layout.scroll.pixel, this.color.axis, { x: 'end' })
                }
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 1 other location - About 3 hrs to fix
          src/chart/cl.chart.scroll.js on lines 310..314

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

          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

                if (this.config.txt.tail !== undefined) {
                  _drawTxt(this.context, this.rectChart.left + this.rectChart.width - this.scale,
                    this.rectChart.top + spaceY, this.config.txt.tail,
                    this.layout.scroll.font, this.layout.scroll.pixel, this.color.axis, { x: 'end' })
                }
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 1 other location - About 3 hrs to fix
          src/chart/cl.chart.scroll.js on lines 335..339

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

          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

                if (this.config.txt.head !== undefined) {
                  _drawTxt(this.context, this.rectChart.left + this.scale, this.rectChart.top + spaceY,
                    this.config.txt.head,
                    this.layout.scroll.font, this.layout.scroll.pixel, this.color.axis)
                }
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 1 other location - About 2 hrs to fix
          src/chart/cl.chart.scroll.js on lines 330..334

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

          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

                if (this.config.txt.left !== undefined && this.rectMid.width > len) {
                  _drawTxt(this.context, this.rectMid.left + this.scale, this.rectMid.top + spaceY,
                    this.config.txt.left,
                    this.layout.scroll.font, this.layout.scroll.pixel, this.color.axis)
                }
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 1 other location - About 2 hrs to fix
          src/chart/cl.chart.scroll.js on lines 305..309

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

          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

                  this.rectMax = {
                    left: stop - this.layout.scroll.size / 2,
                    top: this.rectMain.top + this.scale,
                    width: this.layout.scroll.size,
                    height: spaceY
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 1 other location - About 2 hrs to fix
          src/chart/cl.chart.scroll.js on lines 98..103

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

          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

                  this.rectMin = {
                    left: start - this.layout.scroll.size / 2,
                    top: this.rectMain.top + this.scale,
                    width: this.layout.scroll.size,
                    height: spaceY
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 1 other location - About 2 hrs to fix
          src/chart/cl.chart.scroll.js on lines 104..109

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

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

            drawClear () {
              _fillRect(this.context, this.rectMain.left, this.rectMain.top, this.rectMain.width, this.rectMain.height, this.color.back)
            }
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 3 other locations - About 1 hr to fix
          src/chart/cl.chart.board.js on lines 139..141
          src/chart/cl.chart.report.js on lines 122..124
          src/plugins/cl.super.js on lines 113..115

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

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

                _drawRect(this.context, this.rectMid.left, this.rectMid.top,
                  this.rectMid.width, this.rectMid.height)
          Severity: Major
          Found in src/chart/cl.chart.scroll.js and 5 other locations - About 35 mins to fix
          src/chart/cl.chart.board.js on lines 228..228
          src/chart/cl.chart.board.js on lines 425..425
          src/chart/cl.chart.button.js on lines 155..155
          src/chart/cl.chart.line.js on lines 544..544
          src/plugins/cl.super.js on lines 280..280

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

          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