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

Scan for unnecessary scopes #82

Open
Zankoas opened this issue Jan 21, 2020 · 2 comments
Open

Scan for unnecessary scopes #82

Zankoas opened this issue Jan 21, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Zankoas
Copy link
Contributor

Zankoas commented Jan 21, 2020

A minor but annoying thing I have noticed is a lot of unnecessary or duplicate scoping. There are three examples I can name of the top of my head, but they are all broadly the same thing.

trigger = {
	NOT = {
		is_in_faction_with = GER
	}
	NOT = {
		has_government = totalist
	}
}

Is clearly just a longer version of

trigger = {
	NOT = {
		is_in_faction_with = GER
		has_government = totalist
	}
}

Again here

trigger = {
	JAP = {
		is_in_faction_with = GER
	}
	JAP = {
		has_government = totalist
	}
}

Can be shorten to

trigger = {
	JAP = {
		is_in_faction_with = GER
		has_government = totalist
	}
}

Finally, mistakes like this

trigger = {
	JAP = {
		is_in_faction_with = GER
		JAP = {
			has_government = totalist
		}
	}
}

Which can be cut down

trigger = {
	JAP = {
		is_in_faction_with = GER
		has_government = totalist
	}
}

None of these are major errors, but they do make code longer and harder to read, and now can also be a sign of a bug where someone meant to type in a different scope

@Zankoas Zankoas added the enhancement New feature or request label Jan 21, 2020
@Zankoas
Copy link
Contributor Author

Zankoas commented Jan 21, 2020

Some people also use OR where it isn't needed, but I think that's fine, can make long code blocks with lots of NOT and OR in easier. Though, if possible, I will say that:

trigger = {
	OR = {
		is_in_faction_with = GER
		has_government = totalist
		OR = {
			has_capitulated = yes
			is_subject_of = ROOT
		}
	}
}

Should throw an error, as that isn't more clear than

trigger = {
	OR = {
		is_in_faction_with = GER
		has_government = totalist
		has_capitulated = yes
		is_subject_of = ROOT
	}
}

Although that one is really rare, so don't worry about it if it is a pain to do.

@Zankoas Zankoas added the good first issue Good for newcomers label Feb 26, 2020
@CaligulaCaesar
Copy link

Another one people often do is scoping to ROOT (or even worse, THIS) when they are already in ROOT scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants