Showing 60 of 115 total issues
Function buildUser
has a Cognitive Complexity of 86 (exceeds 20 allowed). Consider refactoring. Open
Open
func buildUser(usr *admin.User) *model.User {
if usr == nil {
return nil
}
- 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
File scim.go
has 712 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
package aws
import (
"bytes"
"context"
Function buildUser
has 183 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func buildUser(usr *admin.User) *model.User {
if usr == nil {
return nil
}
Function membersDataSets
has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring. Open
Open
func membersDataSets(idp, scim []*GroupMembers) (create, equal, remove []*GroupMembers) {
idpMemberSet := make(map[string]map[string]Member)
scimMemberSet := make(map[string]map[string]Member)
scimGroupsSet := make(map[string]Group)
- 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 SCIMService.CreateOrGetUser
has 130 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *SCIMService) CreateOrGetUser(ctx context.Context, cur *CreateUserRequest) (*CreateUserResponse, error) {
if cur == nil {
return nil, ErrCreateUserRequestEmpty
}
if err := cur.Validate(); err != nil {
Function buildUser
has 107 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func buildUser(user *aws.User) *model.User {
if user == nil {
return nil
}
Method SyncService.SyncGroupsAndTheirMembers
has 95 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (ss *SyncService) SyncGroupsAndTheirMembers(ctx context.Context) error {
log.WithFields(log.Fields{
"group_filter": ss.provGroupsFilter,
}).Info("getting identity provider data")
Function membersDataSets
has 82 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func membersDataSets(idp, scim []*GroupMembers) (create, equal, remove []*GroupMembers) {
idpMemberSet := make(map[string]map[string]Member)
scimMemberSet := make(map[string]map[string]Member)
scimGroupsSet := make(map[string]Group)
UserBuilderChoice
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type UserBuilderChoice struct {
u *User
}
Method State.SetHashCode
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *State) SetHashCode() {
// we need to do a deep copy of the state struct to avoid SCIMID in the hash calculation
// because every time the idp data is compared with the state data, the SCIMID doesn't compute in the hash
if s.Resources == nil {
Function buildPutUserRequest
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func buildPutUserRequest(user *model.User) *aws.PutUserRequest {
if user == nil {
return nil
}
Function buildCreateUserRequest
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func buildCreateUserRequest(user *model.User) *aws.CreateUserRequest {
if user == nil {
return nil
}
Function stateSync
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func stateSync(
ctx context.Context,
state *model.State,
scim SCIMService,
idpGroupsResult *model.GroupsResult,
Function syncGroups
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func syncGroups() error {
log.WithFields(
log.Fields{"codeVersion": version.Version},
).Info("starting sync groups")
timeStart := time.Now()
Function initConfig
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func initConfig() {
viper.SetEnvPrefix("idpscim") // allow to read in from environment
envVars := []string{
"log_level",
Method User.MarshalBinary
has 17 return statements (exceeds 4 allowed). Open
Open
func (u User) MarshalBinary() ([]byte, error) {
buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf)
if err := enc.Encode(u.IPID); err != nil {
Method User.UnmarshalBinary
has 17 return statements (exceeds 4 allowed). Open
Open
func (u *User) UnmarshalBinary(data []byte) error {
dec := gob.NewDecoder(bytes.NewReader(data))
if err := dec.Decode(&u.IPID); err != nil {
return err
Method SCIMService.CreateOrGetGroup
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *SCIMService) CreateOrGetGroup(ctx context.Context, cgr *CreateGroupRequest) (*CreateGroupResponse, error) {
if cgr == nil {
return nil, ErrCreateGroupRequestEmpty
}
if err := cgr.Validate(); err != nil {
Function scimSync
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func scimSync(
ctx context.Context,
scim SCIMService,
idpGroupsResult *model.GroupsResult,
idpUsersResult *model.UsersResult,
Method Provider.CreateGroupsMembers
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *Provider) CreateGroupsMembers(ctx context.Context, gmr *model.GroupsMembersResult) (*model.GroupsMembersResult, error) {
groupsMembers := make([]*model.GroupMembers, 0)
for _, groupMembers := range gmr.Resources {
members := make([]*model.Member, 0)