minepkg/minepkg

View on GitHub

Showing 106 of 129 total issues

Method bumpRunner.RunE has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

func (b *bumpRunner) RunE(cmd *cobra.Command, args []string) error {

    instance, err := instances.NewFromWd()

    if err != nil {
Severity: Minor
Found in cmd/bump/bump.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 launchRunner.formatApiError has 56 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (l *launchRunner) formatApiError(err error) error {
    var notFoundErr *api.ErrNoMatchingRelease
    if errors.As(err, &notFoundErr) {
        switch notFoundErr.Err {
        case api.ErrProjectDoesNotExist:
Severity: Minor
Found in cmd/launch.go - About 1 hr to fix

    Function prettyApiError has 56 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func prettyApiError(err error) error {
        var notFoundErr *api.ErrNoMatchingRelease
        if errors.As(err, &notFoundErr) {
            switch notFoundErr.Err {
            case api.ErrProjectDoesNotExist:
    Severity: Minor
    Found in cmd/install-minepkg.go - About 1 hr to fix

      Method selfupdateRunner.RunE has 12 return statements (exceeds 4 allowed).
      Open

      func (s *selfupdateRunner) RunE(cmd *cobra.Command, args []string) error {
          toUpdate, err := os.Executable()
          if err != nil {
              return err
          }
      Severity: Major
      Found in cmd/selfupdate.go - About 1 hr to fix

        Method publishRunner.RunE has 12 return statements (exceeds 4 allowed).
        Open

        func (p *publishRunner) RunE(cmd *cobra.Command, args []string) error {
            apiClient := root.MinepkgAPI
            nonInteractive := viper.GetBool("nonInteractive")
        
            tasks := logger.NewTask(3)
        Severity: Major
        Found in cmd/publish.go - About 1 hr to fix

          Method MinepkgClient.FindRelease has 12 return statements (exceeds 4 allowed).
          Open

          func (m *MinepkgClient) FindRelease(ctx context.Context, project string, reqs *RequirementQuery) (*Release, error) {
              p := Project{client: m, Name: project}
          
              var wantedMCSemver *semver.Version
              if reqs.Minecraft != "*" {
          Severity: Major
          Found in internals/api/find-release.go - About 1 hr to fix

            Method Reader.ExtractModpack has 53 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (p *Reader) ExtractModpack(dest string) error {
                zipReader := p.zipReader
            
                skipPrefixes := []string{}
                createdDirs := make(map[string]interface{})
            Severity: Minor
            Found in internals/pack/pack.go - About 1 hr to fix

              Method Java.Update has 11 return statements (exceeds 4 allowed).
              Open

              func (j *Java) Update(ctx context.Context) error {
                  // remove everything
                  if err := os.RemoveAll(j.dir); err != nil {
                      return err
                  }
              Severity: Major
              Found in internals/java/java.go - About 1 hr to fix

                Method Instance.resolveFabricRequirement has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (i *Instance) resolveFabricRequirement(ctx context.Context) (*manifest.FabricLock, error) {
                    reqMc := i.Manifest.Requirements.Minecraft
                    // latest is the same as '*' for this logic (it will return the latest version)
                    if reqMc == "latest" {
                        reqMc = "*"
                Severity: Minor
                Found in internals/instances/requirements.go - About 1 hr to fix

                  Function dependenciesInSync has 51 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func dependenciesInSync(lock *manifest.Lockfile, mani *manifest.Manifest) (bool, error) {
                      if mani == nil {
                          return false, fmt.Errorf("manifest is nil")
                      }
                  
                  
                  Severity: Minor
                  Found in internals/instances/synced.go - About 1 hr to fix

                    Method bumpRunner.RunE has 10 return statements (exceeds 4 allowed).
                    Open

                    func (b *bumpRunner) RunE(cmd *cobra.Command, args []string) error {
                    
                        instance, err := instances.NewFromWd()
                    
                        if err != nil {
                    Severity: Major
                    Found in cmd/bump/bump.go - About 1 hr to fix

                      Method Rule.appliesFor has 10 return statements (exceeds 4 allowed).
                      Open

                      func (r Rule) appliesFor(os string, arch string) bool {
                          if os == "darwin" {
                              os = "osx"
                          }
                      
                      
                      Severity: Major
                      Found in internals/minecraft/rules.go - About 1 hr to fix

                        Method bumpRunner.gitChecks has 10 return statements (exceeds 4 allowed).
                        Open

                        func (b *bumpRunner) gitChecks() error {
                            dirty, err := utils.SimpleGitExec("status --porcelain")
                            if err != nil {
                                return err
                            }
                        Severity: Major
                        Found in cmd/bump/checks.go - About 1 hr to fix

                          Method Instance.fetchVanillaManifest has 10 return statements (exceeds 4 allowed).
                          Open

                          func (i *Instance) fetchVanillaManifest(version string) (*minecraft.LaunchManifest, error) {
                              mcVersions, err := GetMinecraftReleases(context.TODO())
                              if err != nil {
                                  return nil, err
                              }
                          Severity: Major
                          Found in internals/instances/launch.go - About 1 hr to fix

                            Method MicrosoftClient.GetMinecraftCredentials has 9 return statements (exceeds 4 allowed).
                            Open

                            func (m *MicrosoftClient) GetMinecraftCredentials(ctx context.Context) (*Credentials, error) {
                                if m.Token == nil {
                                    return nil, fmt.Errorf("no token set")
                                }
                            
                            
                            Severity: Major
                            Found in internals/minecraft/microsoft/microsoft.go - About 55 mins to fix

                              Method initRunner.RunE has 9 return statements (exceeds 4 allowed).
                              Open

                              func (i *initRunner) RunE(cmd *cobra.Command, args []string) error {
                                  if _, err := ioutil.ReadFile("./minepkg.toml"); err == nil && !i.force {
                                      return fmt.Errorf("this directory already contains a minepkg.toml. Use --force to overwrite it")
                                  }
                              
                              
                              Severity: Major
                              Found in cmd/initCmd/initCmd.go - About 55 mins to fix

                                Function dependenciesInSync has 9 return statements (exceeds 4 allowed).
                                Open

                                func dependenciesInSync(lock *manifest.Lockfile, mani *manifest.Manifest) (bool, error) {
                                    if mani == nil {
                                        return false, fmt.Errorf("manifest is nil")
                                    }
                                
                                
                                Severity: Major
                                Found in internals/instances/synced.go - About 55 mins to fix

                                  Method initRunner.RunE has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  func (i *initRunner) RunE(cmd *cobra.Command, args []string) error {
                                      if _, err := ioutil.ReadFile("./minepkg.toml"); err == nil && !i.force {
                                          return fmt.Errorf("this directory already contains a minepkg.toml. Use --force to overwrite it")
                                      }
                                  
                                  
                                  Severity: Minor
                                  Found in cmd/initCmd/initCmd.go - About 55 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

                                  Method HTTPItem.Download has 9 return statements (exceeds 4 allowed).
                                  Open

                                  func (i *HTTPItem) Download(ctx context.Context) error {
                                      err := os.MkdirAll(filepath.Dir(i.Target), os.ModePerm)
                                      if err != nil {
                                          return err
                                      }
                                  Severity: Major
                                  Found in internals/downloadmgr/http.go - About 55 mins to fix

                                    Function addToZip has 9 return statements (exceeds 4 allowed).
                                    Open

                                    func addToZip(archive *zip.Writer, path string, filter ...filter) (int, error) {
                                        addCount := 0
                                        filepath.Walk(path, func(origPath string, info os.FileInfo, err error) error {
                                            if err != nil {
                                                return err
                                    Severity: Major
                                    Found in cmd/publish.go - About 55 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language