nuts-foundation/nuts-auth

View on GitHub

Showing 32 of 34 total issues

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

    "EN": {"PractitionerLogin": {
        "v1": &Template{
            Type:               "PractitionerLogin",
            Version:            "v1",
            Language:           "EN",
Severity: Major
Found in pkg/contract/store.go and 1 other location - About 3 hrs to fix
pkg/contract/store.go on lines 29..57

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

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

    "NL": {"BehandelaarLogin": {
        "v1": &Template{
            Type:               "BehandelaarLogin",
            Version:            "v1",
            Language:           "NL",
Severity: Major
Found in pkg/contract/store.go and 1 other location - About 3 hrs to fix
pkg/contract/store.go on lines 58..86

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

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

    for _, chain := range chains {
        root := chain[len(chain)-1]
        vendor, err = cert.VendorIDFromCertificate(root)
        if err != nil {
            logging.Log().Warnf("no vendorID in SAN for %s", root.Subject.String())
Severity: Minor
Found in pkg/services/oauth/oauth.go and 1 other location - About 40 mins to fix
pkg/services/oauth/oauth.go on lines 252..263

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

    for _, chain := range chains {
        root := chain[len(chain)-1]
        vendor, err = cert.VendorIDFromCertificate(root)
        if err != nil {
            logging.Log().Warnf("no vendorID in SAN for %s", root.Subject.String())
Severity: Minor
Found in pkg/services/oauth/oauth.go and 1 other location - About 40 mins to fix
pkg/services/oauth/oauth.go on lines 209..220

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

Method JwtX509Validator.checkCertRevocation has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
Open

func (validator JwtX509Validator) checkCertRevocation(verifiedChain []*x509.Certificate) error {
    for i, certToCheck := range verifiedChain {
        // issuer is normally the next cert in the chain, except for the root which is self signed
        issuerIdx := 1 + i
        if issuerIdx == len(verifiedChain) {
Severity: Minor
Found in pkg/services/x509/x509_validator.go - About 25 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

Your code does not pass gofmt in 2 places. Go fmt your code!
Open

/*
Severity: Minor
Found in pkg/services/irma/irmacontract.go by gofmt

exported func NewMemoryCrlService returns unexported type x509.memoryCrlService, which can be annoying to use
Open

func NewMemoryCrlService() memoryCrlService {
Severity: Minor
Found in pkg/services/x509/crl.go by golint

exported const AmsterdamTimeZone should have comment or be unexported
Open

const AmsterdamTimeZone = "Europe/Amsterdam"
Severity: Minor
Found in pkg/contract/contract.go by golint

exported const ValidToAttr should have comment or be unexported
Open

const ValidToAttr = "valid_to"
Severity: Minor
Found in pkg/contract/template.go by golint

exported type CrlGetter should have comment or be unexported
Open

type CrlGetter interface {
Severity: Minor
Found in pkg/services/x509/crl.go by golint

comment on exported const ActingPartyAttr should be of the form "ActingPartyAttr ..."
Open

// deprecated
Severity: Minor
Found in pkg/contract/template.go by golint

exported const InvalidContract should have comment or be unexported
Open

const InvalidContract = `
Severity: Minor
Found in testdata/contracts.go by golint

type HttpCrlService should be HTTPCrlService
Open

type HttpCrlService struct {
Severity: Minor
Found in pkg/services/x509/crl.go by golint

comment on exported const IrmaMountPath should be of the form "IrmaMountPath ..."
Open

// The location the irma webserver will mount
Severity: Minor
Found in pkg/services/irma/irmaconfig.go by golint

exported function NewCachedHttpCrlService should have comment or be unexported
Open

func NewCachedHttpCrlService() *cachedHttpCrlService {
Severity: Minor
Found in pkg/services/x509/crl.go by golint

exported const ValidIrmaContract should have comment or be unexported
Open

const ValidIrmaContract = `
Severity: Minor
Found in testdata/contracts.go by golint

exported const ConfEnableCORS should have comment or be unexported
Open

const ConfEnableCORS = "enableCORS"
Severity: Minor
Found in pkg/auth.go by golint

exported var ErrInvalidPeriod should have comment or be unexported
Open

var ErrInvalidPeriod = fmt.Errorf("%w: invalid period", ErrInvalidContractText)
Severity: Minor
Found in pkg/contract/contract.go by golint

exported method TemplateStore.FindFromRawContractText should have comment or be unexported
Open

func (m TemplateStore) FindFromRawContractText(rawContractText string) (*Template, error) {
Severity: Minor
Found in pkg/contract/store.go by golint

exported function RegisterVendor should have comment or be unexported
Open

func RegisterVendor(t *testing.T, name string, crypto crypto.Client, registry registry.RegistryClient) {
Severity: Minor
Found in test/util.go by golint
Severity
Category
Status
Source
Language