Showing 91 of 102 total issues
Method Vault.Import
has 14 return statements (exceeds 4 allowed). Open
Open
func (c *Vault) Import(ctx context.Context, pk crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
keyName, ok, err := opt.GetString("name")
if err != nil {
return nil, fmt.Errorf("(CloudKMS/%s): %w", c.config.keyRingName(), err)
}
Method JWK.PrivateKey
has 14 return statements (exceeds 4 allowed). Open
Open
func (j *JWK) PrivateKey() (crypto.PrivateKey, error) {
switch j.KeyType {
case "EC", "EC-HSM":
if j.D == "" {
return nil, ErrPublic
Consider simplifying this complex logical expression. Open
Open
if c >= 32 && c <= 126 && !((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
Function ParseMap
has 13 return statements (exceeds 4 allowed). Open
Open
func ParseMap(s string, namevalSep, tuplesSep rune) (res map[string]string, err error) {
res = make(map[string]string)
p := []byte(s)
for {
p, err = eatSpace(p)
Method JWT.CheckUpdateNewCred
has 12 return statements (exceeds 4 allowed). Open
Open
func (j *JWT) CheckUpdateNewCred() error {
for user, data := range j.Users {
if data.NewData != nil {
if data.NewData.Password == data.Password || data.NewData.Secret == data.Secret {
return fmt.Errorf("JWT: new credentials are same as old for user %s", user)
Function NewRootCommand
has 12 return statements (exceeds 4 allowed). Open
Open
func NewRootCommand(c *Context, name string) *cobra.Command {
var (
level string
configFile string
baseDir string
Method JWK.PrivateKey
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (j *JWK) PrivateKey() (crypto.PrivateKey, error) {
switch j.KeyType {
case "EC", "EC-HSM":
if j.D == "" {
return nil, ErrPublic
Method App.GetAppVersion
has 11 return statements (exceeds 4 allowed). Open
Open
func (a *App) GetAppVersion() (*Version, error) {
res, err := a.Exchange(&APDUCommand{
Cla: claGlobal,
Ins: insVersion,
})
Function Footer
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
function Footer() {
const footerContainer = useRef(null);
const [isActive, setIsActive] = useState(false);
const { footer } = useThemeConfig();
const { copyright, links = [], logo = {} } = footer || {};
- Read upRead up
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 azureIterator.Next
has 11 return statements (exceeds 4 allowed). Open
Open
func (a *azureIterator) Next() (key vault.StoredKey, err error) {
if a.done {
return nil, vault.ErrDone
}
Function NewServeCommand
has 11 return statements (exceeds 4 allowed). Open
Open
func NewServeCommand(c *Context) *cobra.Command {
var noList bool
serveCmd := cobra.Command{
Use: "serve",
Method Vault.Import
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (v *Vault) Import(ctx context.Context, priv crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
keyName, ok, err := opt.GetString("name")
if err != nil {
return nil, fmt.Errorf("(Azure/%s): %w", v.config.Vault, err)
}
Function NewGenKeyCommand
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func NewGenKeyCommand() *cobra.Command {
var (
keyType string
num int
)
Method App.GetAppVersion
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (a *App) GetAppVersion() (*Version, error) {
res, err := a.Exchange(&APDUCommand{
Cla: claGlobal,
Ins: insVersion,
})
Method Vault.Import
has 9 return statements (exceeds 4 allowed). Open
Open
func (v *Vault) Import(ctx context.Context, priv crypt.PrivateKey, opt utils.Options) (vault.StoredKey, error) {
keyName, ok, err := opt.GetString("name")
if err != nil {
return nil, fmt.Errorf("(Azure/%s): %w", v.config.Vault, err)
}
Method JWT.Authenticate
has 8 return statements (exceeds 4 allowed). Open
Open
func (j *JWT) Authenticate(user string, token string) (string, error) {
var tok *jwt.Token
var err error
ud, ok := j.GetUserData(user)
if ok {
Method Vault.SignMessage
has 8 return statements (exceeds 4 allowed). Open
Open
func (v *Vault) SignMessage(ctx context.Context, message []byte, key vault.StoredKey) (crypt.Signature, error) {
digest := crypt.DigestFunc(message)
azureKey, ok := key.(*azureKey)
if !ok {
return nil, errors.Wrap(fmt.Errorf("(Azure/%s): not a Azure key: %T", v.config.Vault, key), http.StatusBadRequest)
Function NewImportCommand
has 8 return statements (exceeds 4 allowed). Open
Open
func NewImportCommand(c *Context) *cobra.Command {
var (
vaultName string
password string
opt string
Method Vault.request
has 7 return statements (exceeds 4 allowed). Open
Open
func (v *Vault) request(ctx context.Context, client *http.Client, method, url string, body io.Reader, result interface{}) (status int, err error) {
req, err := http.NewRequestWithContext(ctx, method, url, body)
if err != nil {
return status, err
}
Function NewAuthRequestCommand
has 7 return statements (exceeds 4 allowed). Open
Open
func NewAuthRequestCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "authenticate <secret key> <request pkh> <request body>",
Short: "Authenticate (sign) a sign request",
Args: cobra.ExactArgs(3),