dlminvestments/dlm--infrastructure-pipeline

View on GitHub

Showing 12 of 12 total issues

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

func (a *AuditBroker) LogResponse(ctx context.Context, in *logical.LogInput, headersConfig *AuditedHeadersConfig) (ret error) {
    defer metrics.MeasureSince([]string{"audit", "log_response"}, time.Now())
    a.RLock()
    defer a.RUnlock()

Severity: Major
Found in vault/audit_broker.go and 1 other location - About 7 hrs to fix
vault/audit_broker.go on lines 90..148

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

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 (a *AuditBroker) LogRequest(ctx context.Context, in *logical.LogInput, headersConfig *AuditedHeadersConfig) (ret error) {
    defer metrics.MeasureSince([]string{"audit", "log_request"}, time.Now())
    a.RLock()
    defer a.RUnlock()

Severity: Major
Found in vault/audit_broker.go and 1 other location - About 7 hrs to fix
vault/audit_broker.go on lines 152..204

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

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

Method LinterAligncheck.ComputeMetric has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
Open

func (l *LinterAligncheck) ComputeMetric(projectPath string) []string {
    importPaths := []string{projectPath}
    if len(importPaths) == 0 {
        importPaths = []string{"."}
    }
Severity: Minor
Found in goreporter/linters/aligncheck/aligncheck.go - About 2 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 LinterAligncheck.ComputeMetric has 68 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (l *LinterAligncheck) ComputeMetric(projectPath string) []string {
    importPaths := []string{projectPath}
    if len(importPaths) == 0 {
        importPaths = []string{"."}
    }
Severity: Minor
Found in goreporter/linters/aligncheck/aligncheck.go - About 1 hr to fix

    Method MySQL.executePreparedStatementsWithMap has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func (m *MySQL) executePreparedStatementsWithMap(ctx context.Context, statements []string, queryMap map[string]string) error {
        // Grab the lock
        m.Lock()
        defer m.Unlock()
    
    
    Severity: Minor
    Found in database/mysql/mysql.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 MongoDB.Initialize has 10 return statements (exceeds 4 allowed).
    Open

    func (m *MongoDB) Initialize(ctx context.Context, req dbplugin.InitializeRequest) (dbplugin.InitializeResponse, error) {
        m.Lock()
        defer m.Unlock()
    
        m.RawConfig = req.Config
    Severity: Major
    Found in database/MongoDB/mongodb.go - About 1 hr to fix

      Method MySQL.executePreparedStatementsWithMap has 7 return statements (exceeds 4 allowed).
      Open

      func (m *MySQL) executePreparedStatementsWithMap(ctx context.Context, statements []string, queryMap map[string]string) error {
          // Grab the lock
          m.Lock()
          defer m.Unlock()
      
      
      Severity: Major
      Found in database/mysql/mysql.go - About 45 mins to fix

        Method MongoDB.NewUser has 6 return statements (exceeds 4 allowed).
        Open

        func (m *MongoDB) NewUser(ctx context.Context, req dbplugin.NewUserRequest) (dbplugin.NewUserResponse, error) {
            // Grab the lock
            m.Lock()
            defer m.Unlock()
        
        
        Severity: Major
        Found in database/MongoDB/mongodb.go - About 40 mins to fix

          Method Client.Authenticate has 6 return statements (exceeds 4 allowed).
          Open

          func (c *Client) Authenticate(username, password, otpseed string) error {
              setPassword := func(values url.Values) {
                  values.Set("login", username)
                  values.Set("password", password)
              }
          Severity: Major
          Found in scrape/scrape.go - About 40 mins to fix

            Method Client.get has 5 return statements (exceeds 4 allowed).
            Open

            func (c *Client) get(urlStr string, a ...interface{}) (*goquery.Document, error) {
                u, err := c.baseURL.Parse(fmt.Sprintf(urlStr, a...))
                if err != nil {
                    return nil, fmt.Errorf("error parsing URL: %q: %v", urlStr, err)
                }
            Severity: Major
            Found in scrape/scrape.go - About 35 mins to fix

              Method Client.AppRestrictionsEnabled has 5 return statements (exceeds 4 allowed).
              Open

              func (c *Client) AppRestrictionsEnabled(org string) (bool, error) {
                  doc, err := c.get("/organizations/%s/settings/oauth_application_policy", org)
                  if err != nil {
                      return false, err
                  }
              Severity: Major
              Found in scrape/apps.go - About 35 mins to fix

                Method MySQL.Initialize has 5 return statements (exceeds 4 allowed).
                Open

                func (m *MySQL) Initialize(ctx context.Context, req dbplugin.InitializeRequest) (dbplugin.InitializeResponse, error) {
                    usernameTemplate, err := strutil.GetString(req.Config, "username_template")
                    if err != nil {
                        return dbplugin.InitializeResponse{}, err
                    }
                Severity: Major
                Found in database/mysql/mysql.go - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language