Showing 106 of 129 total issues
Method bumpRunner.RunE
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func (b *bumpRunner) RunE(cmd *cobra.Command, args []string) error {
instance, err := instances.NewFromWd()
if err != 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
Method launchRunner.formatApiError
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (l *launchRunner) formatApiError(err error) error {
var notFoundErr *api.ErrNoMatchingRelease
if errors.As(err, ¬FoundErr) {
switch notFoundErr.Err {
case api.ErrProjectDoesNotExist:
Function prettyApiError
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func prettyApiError(err error) error {
var notFoundErr *api.ErrNoMatchingRelease
if errors.As(err, ¬FoundErr) {
switch notFoundErr.Err {
case api.ErrProjectDoesNotExist:
Method selfupdateRunner.RunE
has 12 return statements (exceeds 4 allowed). Open
Open
func (s *selfupdateRunner) RunE(cmd *cobra.Command, args []string) error {
toUpdate, err := os.Executable()
if err != nil {
return err
}
Method publishRunner.RunE
has 12 return statements (exceeds 4 allowed). Open
Open
func (p *publishRunner) RunE(cmd *cobra.Command, args []string) error {
apiClient := root.MinepkgAPI
nonInteractive := viper.GetBool("nonInteractive")
tasks := logger.NewTask(3)
Method MinepkgClient.FindRelease
has 12 return statements (exceeds 4 allowed). Open
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 != "*" {
Method Reader.ExtractModpack
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *Reader) ExtractModpack(dest string) error {
zipReader := p.zipReader
skipPrefixes := []string{}
createdDirs := make(map[string]interface{})
Method Java.Update
has 11 return statements (exceeds 4 allowed). Open
Open
func (j *Java) Update(ctx context.Context) error {
// remove everything
if err := os.RemoveAll(j.dir); err != nil {
return err
}
Method Instance.resolveFabricRequirement
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
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 = "*"
Function dependenciesInSync
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func dependenciesInSync(lock *manifest.Lockfile, mani *manifest.Manifest) (bool, error) {
if mani == nil {
return false, fmt.Errorf("manifest is nil")
}
Method bumpRunner.RunE
has 10 return statements (exceeds 4 allowed). Open
Open
func (b *bumpRunner) RunE(cmd *cobra.Command, args []string) error {
instance, err := instances.NewFromWd()
if err != nil {
Method Rule.appliesFor
has 10 return statements (exceeds 4 allowed). Open
Open
func (r Rule) appliesFor(os string, arch string) bool {
if os == "darwin" {
os = "osx"
}
Method bumpRunner.gitChecks
has 10 return statements (exceeds 4 allowed). Open
Open
func (b *bumpRunner) gitChecks() error {
dirty, err := utils.SimpleGitExec("status --porcelain")
if err != nil {
return err
}
Method Instance.fetchVanillaManifest
has 10 return statements (exceeds 4 allowed). Open
Open
func (i *Instance) fetchVanillaManifest(version string) (*minecraft.LaunchManifest, error) {
mcVersions, err := GetMinecraftReleases(context.TODO())
if err != nil {
return nil, err
}
Method MicrosoftClient.GetMinecraftCredentials
has 9 return statements (exceeds 4 allowed). Open
Open
func (m *MicrosoftClient) GetMinecraftCredentials(ctx context.Context) (*Credentials, error) {
if m.Token == nil {
return nil, fmt.Errorf("no token set")
}
Method initRunner.RunE
has 9 return statements (exceeds 4 allowed). Open
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")
}
Function dependenciesInSync
has 9 return statements (exceeds 4 allowed). Open
Open
func dependenciesInSync(lock *manifest.Lockfile, mani *manifest.Manifest) (bool, error) {
if mani == nil {
return false, fmt.Errorf("manifest is nil")
}
Method initRunner.RunE
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
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")
}
- 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 HTTPItem.Download
has 9 return statements (exceeds 4 allowed). Open
Open
func (i *HTTPItem) Download(ctx context.Context) error {
err := os.MkdirAll(filepath.Dir(i.Target), os.ModePerm)
if err != nil {
return err
}
Function addToZip
has 9 return statements (exceeds 4 allowed). Open
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