Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revive: the default config is only applied when no dedicated config #1831

Merged
merged 1 commit into from Mar 15, 2021

Conversation

ldez
Copy link
Member

@ldez ldez commented Mar 10, 2021

Fix #1770

#1770 (comment)

The code from revive:

// GetConfig yields the configuration
func GetConfig(configPath string) (*lint.Config, error) {
	config := defaultConfig()
	if configPath != "" {
		var err error
		config, err = parseConfig(configPath)
		if err != nil {
			return nil, err
		}
	}
	normalizeConfig(config)
	return config, nil
}

The same thing in this PR:

func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
	conf := defaultConfig()

	if !reflect.DeepEqual(cfg, &config.ReviveSettings{}) {
		rawRoot := createConfigMap(cfg)
		buf := bytes.NewBuffer(nil)

		err := toml.NewEncoder(buf).Encode(rawRoot)
		if err != nil {
			return nil, err
		}

		conf = &lint.Config{}
		_, err = toml.DecodeReader(buf, conf)
		if err != nil {
			return nil, err
		}
	}

	normalizeConfig(conf)

Copy link
Member

@ernado ernado left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ldez ldez merged commit cd6644d into golangci:master Mar 15, 2021
@ldez ldez deleted the fix/revive-default branch March 15, 2021 11:39
@ldez ldez added this to the v1.39 milestone Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linter: update version Update version of linter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't disable specific revive rules after upgrading from 1.37.0 to 1.37.1
2 participants