minepkg/minepkg

View on GitHub

Showing 106 of 129 total issues

Method joinRunner.RunE has 77 lines of code (exceeds 50 allowed). Consider refactoring.
Open

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

    var resolvedModpack *api.Release
    ip := "127.0.0.1"
    connectionString := strings.Split(args[0], ":")
Severity: Major
Found in cmd/join.go - About 2 hrs to fix

    Method selfupdateRunner.RunE has 75 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

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

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

      func (i *initRunner) emptyDirFinalization(man *manifest.Manifest) error {
          if man.Package.Type == manifest.TypeMod {
              fmt.Println("\nThis directory is empty. Do you want to use a template?")
              q := &promptui.Select{
                  Label: "Template",
      Severity: Minor
      Found in cmd/initCmd/emptyDirFinalization.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 unpublishRunner.RunE has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
      Open

      func (p *unpublishRunner) RunE(cmd *cobra.Command, args []string) error {
          apiClient := root.MinepkgAPI
          // nonInteractive := viper.GetBool("nonInteractive")
      
          var mID *pkgid.ID
      Severity: Minor
      Found in cmd/unpublish.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 MinepkgClient.FindRelease has 72 lines of code (exceeds 50 allowed). Consider refactoring.
      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: Minor
      Found in internals/api/find-release.go - About 1 hr to fix

        Method Launcher.HandleCrash has 72 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *Launcher) HandleCrash() error {
            // exit code was not 130 or 0, we output error info and submit a crash report
            man := c.Instance.Manifest
            platform := man.PlatformString()
        
        
        Severity: Minor
        Found in internals/launcher/handle-crash.go - About 1 hr to fix

          Method Launcher.PrepareMinecraft has 70 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (l *Launcher) PrepareMinecraft(ctx context.Context) error {
              instance := l.Instance
              mgr := downloadmgr.New()
          
              fmt.Println(pipeText.Render(gchalk.Gray("Preparing Minecraft")))
          Severity: Minor
          Found in internals/launcher/prepare.go - About 1 hr to fix

            Method MinepkgClient.OAuthLogin has 69 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (m *MinepkgClient) OAuthLogin(c *OAuthLoginConfig) *oauth2.Token {
            
                // ctx := context.Background()
                conf := &oauth2.Config{
                    ClientID:     "minepkg-cli",
            Severity: Minor
            Found in internals/api/login.go - About 1 hr to fix

              Method initRunner.emptyDirFinalization has 69 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (i *initRunner) emptyDirFinalization(man *manifest.Manifest) error {
                  if man.Package.Type == manifest.TypeMod {
                      fmt.Println("\nThis directory is empty. Do you want to use a template?")
                      q := &promptui.Select{
                          Label: "Template",
              Severity: Minor
              Found in cmd/initCmd/emptyDirFinalization.go - About 1 hr to fix

                Function MergeManifests has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                Open

                func MergeManifests(source *LaunchManifest, manifests ...*LaunchManifest) {
                    for _, new := range manifests {
                        if new == nil {
                            panic("can't merge with nil manifest")
                        }
                Severity: Minor
                Found in internals/minecraft/launcher-manifest.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

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

                func initConfig() {
                    if viper.GetBool("noColor") {
                        gchalk.ForceLevel(gchalk.LevelNone)
                    }
                
                
                Severity: Minor
                Found in cmd/root.go - About 1 hr to fix

                  Method MicrosoftClient.Oauth has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (m *MicrosoftClient) Oauth(ctx context.Context) error {
                      conf := m.Config
                  
                      state := uniuri.New()
                      pkceVerifier := uniuri.NewLen(128)
                  Severity: Minor
                  Found in internals/minecraft/microsoft/1-oauth.go - About 1 hr to fix

                    Method Factory.getAssets has 63 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (j *Factory) getAssets(ctx context.Context, opts *AdoptAssetRequest) ([]AdoptAsset, error) {
                        // set all the defaults
                        if opts.architecture == "" {
                            opts.architecture = archMap(runtime.GOARCH)
                        }
                    Severity: Minor
                    Found in internals/java/adopt.go - About 1 hr to fix

                      Method Instance.launchManifestArgs has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (i *Instance) launchManifestArgs(launchManifest *minecraft.LaunchManifest, opts *LaunchOptions, classPaths string, nativesDir string) ([]string, error) {
                      
                          if launchManifest.MainClass == "" {
                              log.Println("[WARN] launchManifest.MainClass is empty")
                          }
                      Severity: Minor
                      Found in internals/instances/launch.go - About 1 hr to fix

                        Method Launcher.PrepareMinecraft has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (l *Launcher) PrepareMinecraft(ctx context.Context) error {
                            instance := l.Instance
                            mgr := downloadmgr.New()
                        
                            fmt.Println(pipeText.Render(gchalk.Gray("Preparing Minecraft")))
                        Severity: Minor
                        Found in internals/launcher/prepare.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 DownloadManager.Start has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (d *DownloadManager) Start(ctx context.Context) error {
                            sem := make(chan int, 16)
                            cErr := make(chan error)
                        
                            if d.queue == nil {
                        Severity: Minor
                        Found in internals/downloadmgr/manager.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

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

                        func defaultManifest() *manifest.Manifest {
                            fabricMan := &fabric.Manifest{}
                            man := manifest.New()
                        
                            err := utils.ReadJSONFile("./src/main/resources/fabric.mod.json", fabricMan)
                        Severity: Minor
                        Found in cmd/initCmd/defaultManifest.go - About 1 hr to fix

                          Method bumpRunner.gitChecks has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

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

                            Method launchRunner.RunE has 13 return statements (exceeds 4 allowed).
                            Open

                            func (l *launchRunner) RunE(cmd *cobra.Command, args []string) error {
                                var err error
                            
                                vanillaManifest.Requirements.Minecraft = "*"
                                vanillaManifest.Requirements.MinepkgCompanion = "none"
                            Severity: Major
                            Found in cmd/launch.go - About 1 hr to fix

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

                              func (r Rule) appliesFor(os string, arch string) bool {
                                  if os == "darwin" {
                                      os = "osx"
                                  }
                              
                              
                              Severity: Minor
                              Found in internals/minecraft/rules.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

                              Severity
                              Category
                              Status
                              Source
                              Language