tsuz/go-pine

View on GitHub

Showing 45 of 45 total issues

Function getRSIU has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
Open

func getRSIU(stop *Value, vs ValueSeries, rsiu ValueSeries, l int64) ValueSeries {
    firstVal := rsiu.GetLast()

    if firstVal == nil {
        firstVal = vs.GetFirst()
Severity: Minor
Found in pine/series_rsi.go - About 4 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 getRSID has a Cognitive Complexity of 43 (exceeds 20 allowed). Consider refactoring.
Open

func getRSID(stop *Value, vs ValueSeries, rsid ValueSeries, l int64) ValueSeries {
    firstVal := rsid.GetLast()

    if firstVal == nil {
        firstVal = vs.GetFirst()
Severity: Minor
Found in pine/series_rsi.go - About 4 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 getSum has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
Open

func getSum(stop Value, sum ValueSeries, src ValueSeries, l int) ValueSeries {

    // keep track of the source values of sum, maximum of l+1 items
    sumSrc := make([]float64, 0)
    var startNew *Value
Severity: Minor
Found in pine/series_sum.go - 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 SMA has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
Open

func SMA(p ValueSeries, l int64) ValueSeries {
    key := fmt.Sprintf("sma:%s:%d", p.ID(), l)
    sma := getCache(key)
    if sma == nil {
        sma = NewValueSeries()
Severity: Minor
Found in pine/series_sma.go - 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

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

package pine

// Crossover generates ValueSeries of ketler channel's middle, upper and lower in that order.
func Crossover(a, b ValueSeries) ValueSeries {
    c := OperateWithNil(a, b, "crossover", func(av, bv *Value) *Value {
Severity: Major
Found in pine/series_crossover.go and 1 other location - About 2 hrs to fix
pine/series_crossunder.go on lines 1..26

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

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

package pine

// Crossunder generates ValueSeries of ketler channel's middle, upper and lower in that order.
func Crossunder(a, b ValueSeries) ValueSeries {
    c := OperateWithNil(a, b, "crossunder", func(av, bv *Value) *Value {
Severity: Major
Found in pine/series_crossunder.go and 1 other location - About 2 hrs to fix
pine/series_crossover.go on lines 1..26

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

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

Function getRSI has 70 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func getRSI(stop *Value, vs ValueSeries, rsi ValueSeries, l int64) ValueSeries {

    rsiukey := fmt.Sprintf("rsiu:%s:%d", vs.ID(), l)
    rsiu := getCache(rsiukey)
    if rsiu == nil {
Severity: Minor
Found in pine/series_rsi.go - About 1 hr to fix

    Function SMA has 68 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func SMA(p ValueSeries, l int64) ValueSeries {
        key := fmt.Sprintf("sma:%s:%d", p.ID(), l)
        sma := getCache(key)
        if sma == nil {
            sma = NewValueSeries()
    Severity: Minor
    Found in pine/series_sma.go - About 1 hr to fix

      Function getSum has 68 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func getSum(stop Value, sum ValueSeries, src ValueSeries, l int) ValueSeries {
      
          // keep track of the source values of sum, maximum of l+1 items
          sumSrc := make([]float64, 0)
          var startNew *Value
      Severity: Minor
      Found in pine/series_sum.go - About 1 hr to fix

        Function valueWhen has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
        Open

        func valueWhen(stop Value, bs, src, vw ValueSeries, ocr int) ValueSeries {
        
            var val *Value
        
            lastvw := vw.GetCurrent()
        Severity: Minor
        Found in pine/series_value_when.go - 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

        Function getRSIU has 63 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func getRSIU(stop *Value, vs ValueSeries, rsiu ValueSeries, l int64) ValueSeries {
            firstVal := rsiu.GetLast()
        
            if firstVal == nil {
                firstVal = vs.GetFirst()
        Severity: Minor
        Found in pine/series_rsi.go - About 1 hr to fix

          Function getRSID has 63 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func getRSID(stop *Value, vs ValueSeries, rsid ValueSeries, l int64) ValueSeries {
              firstVal := rsid.GetLast()
          
              if firstVal == nil {
                  firstVal = vs.GetFirst()
          Severity: Minor
          Found in pine/series_rsi.go - About 1 hr to fix

            Function getOHLCVAttr has 59 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func getOHLCVAttr(stop OHLCV, src OHLCVSeries, dest ValueSeries, p OHLCProp) ValueSeries {
            
                var startt time.Time
            
                firstVal := dest.GetLast()
            Severity: Minor
            Found in pine/series_ohlcv_attr.go - About 1 hr to fix

              Function DMI has 56 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func DMI(ohlcv OHLCVSeries, len, smoo int) (adx, plus, minus ValueSeries) {
                  adxkey := fmt.Sprintf("adx:%s:%d:%d", ohlcv.ID(), len, smoo)
                  adx = getCache(adxkey)
                  if adx == nil {
                      adx = NewValueSeries()
              Severity: Minor
              Found in pine/series_dmi.go - About 1 hr to fix

                Function roc has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                Open

                func roc(stop Value, src, roc, chg ValueSeries, l int) ValueSeries {
                
                    var val *Value
                
                    lastvw := roc.GetCurrent()
                Severity: Minor
                Found in pine/series_roc.go - 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

                Function roc has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func roc(stop Value, src, roc, chg ValueSeries, l int) ValueSeries {
                
                    var val *Value
                
                    lastvw := roc.GetCurrent()
                Severity: Minor
                Found in pine/series_roc.go - About 1 hr to fix

                  Function valueWhen has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func valueWhen(stop Value, bs, src, vw ValueSeries, ocr int) ValueSeries {
                  
                      var val *Value
                  
                      lastvw := vw.GetCurrent()
                  Severity: Minor
                  Found in pine/series_value_when.go - About 1 hr to fix

                    Function MFI has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func MFI(o OHLCVSeries, l int64) ValueSeries {
                        key := fmt.Sprintf("mfi:%s:%d", o.ID(), l)
                        mfi := getCache(key)
                        if mfi == nil {
                            mfi = NewValueSeries()
                    Severity: Minor
                    Found in pine/series_mfi.go - About 1 hr to fix

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

                      func EMA(p ValueSeries, l int64) ValueSeries {
                          key := fmt.Sprintf("ema:%s:%d", p.ID(), l)
                          ema := getCache(key)
                          if ema == nil {
                              ema = NewValueSeries()
                      Severity: Major
                      Found in pine/series_ema.go and 2 other locations - About 55 mins to fix
                      pine/series_rma.go on lines 9..30
                      pine/series_rsi.go on lines 15..36

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

                      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

                      func RMA(p ValueSeries, l int64) ValueSeries {
                          key := fmt.Sprintf("rma:%s:%d", p.ID(), l)
                          rma := getCache(key)
                          if rma == nil {
                              rma = NewValueSeries()
                      Severity: Major
                      Found in pine/series_rma.go and 2 other locations - About 55 mins to fix
                      pine/series_ema.go on lines 8..29
                      pine/series_rsi.go on lines 15..36

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language