slashdevops/idp-scim-sync

View on GitHub

Showing 60 of 115 total issues

Function buildUser has a Cognitive Complexity of 86 (exceeds 20 allowed). Consider refactoring.
Open

func buildUser(usr *admin.User) *model.User {
    if usr == nil {
        return nil
    }

Severity: Minor
Found in internal/idp/helpers.go - About 1 day 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

File scim.go has 712 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package aws

import (
    "bytes"
    "context"
Severity: Minor
Found in pkg/aws/scim.go - About 7 hrs to fix

    Function buildUser has 183 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func buildUser(usr *admin.User) *model.User {
        if usr == nil {
            return nil
        }
    
    
    Severity: Major
    Found in internal/idp/helpers.go - About 6 hrs to fix

      Function membersDataSets has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
      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)
      
      
      Severity: Minor
      Found in internal/model/operations.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 SCIMService.CreateOrGetUser has 130 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (s *SCIMService) CreateOrGetUser(ctx context.Context, cur *CreateUserRequest) (*CreateUserResponse, error) {
          if cur == nil {
              return nil, ErrCreateUserRequestEmpty
          }
          if err := cur.Validate(); err != nil {
      Severity: Major
      Found in pkg/aws/scim.go - About 4 hrs to fix

        Function buildUser has 107 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func buildUser(user *aws.User) *model.User {
            if user == nil {
                return nil
            }
        
        
        Severity: Major
        Found in internal/scim/helpers.go - About 3 hrs to fix

          Method SyncService.SyncGroupsAndTheirMembers has 95 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (ss *SyncService) SyncGroupsAndTheirMembers(ctx context.Context) error {
              log.WithFields(log.Fields{
                  "group_filter": ss.provGroupsFilter,
              }).Info("getting identity provider data")
          
          
          Severity: Major
          Found in internal/core/sync.go - About 2 hrs to fix

            Function membersDataSets has 82 lines of code (exceeds 50 allowed). Consider refactoring.
            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)
            
            
            Severity: Major
            Found in internal/model/operations.go - About 2 hrs to fix

              UserBuilderChoice has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

              type UserBuilderChoice struct {
                  u *User
              }
              Severity: Minor
              Found in internal/model/user_builder.go - About 2 hrs to fix

                Method State.SetHashCode has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                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 {
                Severity: Major
                Found in internal/model/state.go - About 2 hrs to fix

                  Function buildPutUserRequest has 73 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func buildPutUserRequest(user *model.User) *aws.PutUserRequest {
                      if user == nil {
                          return nil
                      }
                  
                  
                  Severity: Minor
                  Found in internal/scim/helpers.go - About 1 hr to fix

                    Function buildCreateUserRequest has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func buildCreateUserRequest(user *model.User) *aws.CreateUserRequest {
                        if user == nil {
                            return nil
                        }
                    
                    
                    Severity: Minor
                    Found in internal/scim/helpers.go - About 1 hr to fix

                      Function stateSync has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func stateSync(
                          ctx context.Context,
                          state *model.State,
                          scim SCIMService,
                          idpGroupsResult *model.GroupsResult,
                      Severity: Minor
                      Found in internal/core/actions.go - About 1 hr to fix

                        Function syncGroups has 69 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func syncGroups() error {
                            log.WithFields(
                                log.Fields{"codeVersion": version.Version},
                            ).Info("starting sync groups")
                            timeStart := time.Now()
                        Severity: Minor
                        Found in cmd/idpscim/cmd/root.go - About 1 hr to fix

                          Function initConfig has 67 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func initConfig() {
                              viper.SetEnvPrefix("idpscim") // allow to read in from environment
                          
                              envVars := []string{
                                  "log_level",
                          Severity: Minor
                          Found in cmd/idpscim/cmd/root.go - About 1 hr to fix

                            Method User.MarshalBinary has 17 return statements (exceeds 4 allowed).
                            Open

                            func (u User) MarshalBinary() ([]byte, error) {
                                buf := new(bytes.Buffer)
                                enc := gob.NewEncoder(buf)
                            
                                if err := enc.Encode(u.IPID); err != nil {
                            Severity: Major
                            Found in internal/model/user.go - About 1 hr to fix

                              Method User.UnmarshalBinary has 17 return statements (exceeds 4 allowed).
                              Open

                              func (u *User) UnmarshalBinary(data []byte) error {
                                  dec := gob.NewDecoder(bytes.NewReader(data))
                              
                                  if err := dec.Decode(&u.IPID); err != nil {
                                      return err
                              Severity: Major
                              Found in internal/model/user.go - About 1 hr to fix

                                Method SCIMService.CreateOrGetGroup has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (s *SCIMService) CreateOrGetGroup(ctx context.Context, cgr *CreateGroupRequest) (*CreateGroupResponse, error) {
                                    if cgr == nil {
                                        return nil, ErrCreateGroupRequestEmpty
                                    }
                                    if err := cgr.Validate(); err != nil {
                                Severity: Minor
                                Found in pkg/aws/scim.go - About 1 hr to fix

                                  Function scimSync has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func scimSync(
                                      ctx context.Context,
                                      scim SCIMService,
                                      idpGroupsResult *model.GroupsResult,
                                      idpUsersResult *model.UsersResult,
                                  Severity: Minor
                                  Found in internal/core/actions.go - About 1 hr to fix

                                    Method Provider.CreateGroupsMembers has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                                    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)
                                    Severity: Minor
                                    Found in internal/scim/scim.go - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language