aergoio/aergo

View on GitHub
contract/sqlite3.go

Summary

Maintainability
F
4 days
Test Coverage
F
0%

File sqlite3.go has 953 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Copyright (C) 2014 Yasuhiro Matsumoto <mattn.jp@gmail.com>.
// Copyright (C) 2018 G.J.R. Timmer <gjr.timmer@gmail.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
Severity: Major
Found in contract/sqlite3.go - About 1 day to fix

    Method SQLiteRows.Next has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
    Open

    func (rc *SQLiteRows) Next(dest []driver.Value) error {
        rc.s.mu.Lock()
        defer rc.s.mu.Unlock()
        if rc.s.closed {
            return io.EOF
    Severity: Minor
    Found in contract/sqlite3.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

    Method SQLiteConn.RegisterAggregator has 93 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error {
        var ai aggInfo
        ai.constructor = reflect.ValueOf(impl)
        t := ai.constructor.Type()
        if t.Kind() != reflect.Func {
    Severity: Major
    Found in contract/sqlite3.go - About 2 hrs to fix

      SQLiteConn has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type SQLiteConn struct {
          mu          sync.Mutex
          db          *C.sqlite3
          loc         *time.Location
          txlock      string
      Severity: Minor
      Found in contract/sqlite3.go - About 2 hrs to fix

        Method SQLiteRows.Next has 85 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (rc *SQLiteRows) Next(dest []driver.Value) error {
            rc.s.mu.Lock()
            defer rc.s.mu.Unlock()
            if rc.s.closed {
                return io.EOF
        Severity: Major
        Found in contract/sqlite3.go - About 2 hrs to fix

          Method SQLiteConn.RegisterAggregator has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
          Open

          func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error {
              var ai aggInfo
              ai.constructor = reflect.ValueOf(impl)
              t := ai.constructor.Type()
              if t.Kind() != reflect.Func {
          Severity: Minor
          Found in contract/sqlite3.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

          Method SQLiteDriver.Open has 65 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
              if C.sqlite3_threadsafe() == 0 {
                  return nil, errors.New("sqlite library was not compiled for thread-safe operation")
              }
          
          
          Severity: Minor
          Found in contract/sqlite3.go - About 1 hr to fix

            Method SQLiteConn.RegisterAggregator has 16 return statements (exceeds 4 allowed).
            Open

            func (c *SQLiteConn) RegisterAggregator(name string, impl interface{}, pure bool) error {
                var ai aggInfo
                ai.constructor = reflect.ValueOf(impl)
                t := ai.constructor.Type()
                if t.Kind() != reflect.Func {
            Severity: Major
            Found in contract/sqlite3.go - About 1 hr to fix

              Method SQLiteStmt.bind has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
              Open

              func (s *SQLiteStmt) bind(args []namedValue) error {
                  rv := C.sqlite3_reset(s.s)
                  if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
                      return s.c.lastError()
                  }
              Severity: Minor
              Found in contract/sqlite3.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

              Method SQLiteStmt.bind has 52 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (s *SQLiteStmt) bind(args []namedValue) error {
                  rv := C.sqlite3_reset(s.s)
                  if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
                      return s.c.lastError()
                  }
              Severity: Minor
              Found in contract/sqlite3.go - About 1 hr to fix

                Method SQLiteDriver.Open has 10 return statements (exceeds 4 allowed).
                Open

                func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
                    if C.sqlite3_threadsafe() == 0 {
                        return nil, errors.New("sqlite library was not compiled for thread-safe operation")
                    }
                
                
                Severity: Major
                Found in contract/sqlite3.go - About 1 hr to fix

                  Method SQLiteConn.RegisterFunc has 8 return statements (exceeds 4 allowed).
                  Open

                  func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) error {
                      var fi functionInfo
                      fi.f = reflect.ValueOf(impl)
                      t := fi.f.Type()
                      if t.Kind() != reflect.Func {
                  Severity: Major
                  Found in contract/sqlite3.go - About 50 mins to fix

                    Method SQLiteRows.Next has 5 return statements (exceeds 4 allowed).
                    Open

                    func (rc *SQLiteRows) Next(dest []driver.Value) error {
                        rc.s.mu.Lock()
                        defer rc.s.mu.Unlock()
                        if rc.s.closed {
                            return io.EOF
                    Severity: Major
                    Found in contract/sqlite3.go - About 35 mins to fix

                      Method SQLiteDriver.Open has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
                          if C.sqlite3_threadsafe() == 0 {
                              return nil, errors.New("sqlite library was not compiled for thread-safe operation")
                          }
                      
                      
                      Severity: Minor
                      Found in contract/sqlite3.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

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

                      func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, error) {
                          list := make([]namedValue, len(args))
                          for i, v := range args {
                              list[i] = namedValue{
                                  Ordinal: i + 1,
                      Severity: Minor
                      Found in contract/sqlite3.go and 1 other location - About 55 mins to fix
                      contract/sqlite3.go on lines 784..793

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

                      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 (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, error) {
                          list := make([]namedValue, len(args))
                          for i, v := range args {
                              list[i] = namedValue{
                                  Ordinal: i + 1,
                      Severity: Minor
                      Found in contract/sqlite3.go and 1 other location - About 55 mins to fix
                      contract/sqlite3.go on lines 732..741

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

                      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 (s *SQLiteStmt) Query(args []driver.Value) (driver.Rows, error) {
                          list := make([]namedValue, len(args))
                          for i, v := range args {
                              list[i] = namedValue{
                                  Ordinal: i + 1,
                      Severity: Minor
                      Found in contract/sqlite3.go and 1 other location - About 50 mins to fix
                      contract/sqlite3.go on lines 1296..1305

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

                      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 (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
                          list := make([]namedValue, len(args))
                          for i, v := range args {
                              list[i] = namedValue{
                                  Ordinal: i + 1,
                      Severity: Minor
                      Found in contract/sqlite3.go and 1 other location - About 50 mins to fix
                      contract/sqlite3.go on lines 1241..1250

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

                      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