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

Adding configuration and new checks #73

Merged
merged 7 commits into from
Oct 15, 2018

Conversation

davidakachaos
Copy link
Contributor

Added some new checks and a configuration option.
Sorry for not splitting this up correctly, if you want I could try to break this apart.

Master switch if a user wants to check venues or not.
@@ -545,11 +545,14 @@ function F_VALIDATE(disabledHL) {
this.$isApproved = attrs.approved;
this.$mainCategory = raw.getMainCategory();
this.$categories = attrs.categories;
this.$categoryAttributes = attrs.categoryAttributes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add categoryAttributes to the externs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, it should be

src/validate.js Outdated
seen = null;
if ("Delete" === rawVenue.state) continue;
// not in scope of current view.
if (rawVenue.outOfScope && rawVenue.outOfScope === true) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just if (rawVenue.outOfScope) continue;?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

var alts = venue.$alts;
var lock = venue.$lock;

var exceptedCategories ='BRIDGE|ISLAND|FOREST_GROVE|SEA_LAKE_POOL|RIVER_STREAM|CANAL|DAM|TUNNEL|JUNCTION_INTERCHANGE'.split('|');
Copy link
Contributor

Choose a reason for hiding this comment

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

No hard-coded values should be in the code. Those categories should be moved either to i18n as a default value or to the data.js.

'^admin$', '^-1$',
'^avsus$', '^107668852$'
];
var re = new RegExp(botNamesAndIDs.join('|'),'i');
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. The Regex should be created during the initialization. Looks like it belongs to i18n.

&& address.isOkFor(254))
venue.report(254);
//check elevation of the parking lot
if ((!parkAttr || !parkAttr.lotType || parkAttr.lotType.length === 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

The checks !parkAttr.lotType and parkAttr.lotType.length === 0 are the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lotType can be undefined or {} is that both caught by either check? I thought I needed both checks?

Copy link
Contributor

Choose a reason for hiding this comment

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

Any value that is not false, undefined, null, 0, NaN, or the empty string (""), and any object, including a Boolean object whose value is false, is considered truthy when used as the condition.

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else

Copy link
Contributor

Choose a reason for hiding this comment

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

If lotType is an object, I guess there will be no length property there, unless it is added by WME. Do you happen to have a permalink with a parking lot at hand, since there are no parking lots around...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

In the correctly set permalink I see the lotType is an array and it is empty. Sorry, we need to check if the array length is zero, but I am not quite sure why it is empty in the correctly set PL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Empty?
image
I see it with one element in it ("STREET_LEVEL")

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I might have missed the venue. We need to check the length of the array [] is not zero just as you had it before.

src/validate.js Outdated
if (venue.$rawObject.isGasStation()) {
// check if brand in name
if (venue.$name.indexOf(venue.$brand) === -1
&& isLimitOk(259)
Copy link
Contributor

Choose a reason for hiding this comment

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

Overall, it is not necessary to use isLimitOk(), since the venue.report() below will check the limit anyway.

The rationale behind isLimitOk() is to avoid long computations. For example:

if (isLimitOk()) {
    // long check
    if (condition)
        report();

}

In such cases it makes sense, since if the limit is exceeded, we do not even start the "long check" part.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, okay, that makes sense. I need to review the checks then. Thanks for the explanation.


if(venue.$entryExitPoints && venue.$entryExitPoints.length){
var stopPoint = venue.$entryExitPoints[0].getPoint();
var areaCenter = venue.$geometry.getCentroid();
Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite understand this check. And it seems there is no commit in i18n?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This checks if the entry/exit point of a place has not been moved from its original position when created (equal to the center of the venue) I'll check the i18n, 256 should be there or I've forgotten it

@berestovskyy
Copy link
Contributor

Looks good. Do not need to squash yet, we will squash on merge to the master.

I will test the dev branch during the weekend. Maybe we should ask for some volunteers on the forum to test this branch and provide a feedback as well?

@davidakachaos
Copy link
Contributor Author

Okay, we will merge and do a test. Maybe we should put up a test version pre build somewhere, easier for people to test that do not know (or want) how to build.
We could put the script unlisted on GreasyFork and link it on the forum for people to test. If we do that, we can ask people to test the new functions on the forum, discord, slack etc...

@berestovskyy
Copy link
Contributor

Would you like to lead this beta branch?

@davidakachaos
Copy link
Contributor Author

Sorry, had my kids over the weekend so was offline for most of it 😉
I'm willing to help out anyway I can, so yeah, I'll set something up so we can spread it around.

@davidakachaos davidakachaos merged commit 0505a02 into WMEValidator:dev Oct 15, 2018
@davidakachaos
Copy link
Contributor Author

@berestovskyy I've created a beta version of the script and put it on GreasyFork as unlisted here

I want to link it on the forum as a test version using the following text:

Hello everyone! We've created a test version of WME Validator with support for checking venues beside segments. We want to test this out and see if everything works correctly. We've some new checks specially for venues. We would love to hear your feedback on this either here on the forum or via the Github issues! If you're willing to test this version out, please install the beta version of this script via this link (be sure to disable the current install of WME Validator!)

This could be posted to the discord too. Would this be okay?

@berestovskyy
Copy link
Contributor

berestovskyy commented Oct 15, 2018

Sorry, I just realized I have added the beta tag to the main version of Validator :) To avoid confusions, maybe let's call it alpha, experimental, release candidate (RC), daily build, or anything different than beta?

And it would be nice if I or potentially other developers could update this experimental branch as well. I just googled if it's possible to share a script on GF, but it seems not:
greasyfork-org/greasyfork#311

Maybe we better create a repo similar to release:
https://github.com/WMEValidator/release

So we have a bit more flexibility with access permissions. What do you think?

@justins83
Copy link
Contributor

justins83 commented Oct 15, 2018 via email

@davidakachaos
Copy link
Contributor Author

@berestovskyy I'll rename it to alpha then 😄 And I agree, it would be nice to have.
@justins83 We have a build script that needs to be run before we publish. Maybe we need to look into a auto build service? And publish from there?

@justins83
Copy link
Contributor

justins83 commented Oct 16, 2018 via email

@berestovskyy
Copy link
Contributor

IMO a webhook or an automatic sync does not change the fact that we need a shared account on GreasyFork, or do I miss something?

@justins83
Copy link
Contributor

justins83 commented Oct 16, 2018 via email

@berestovskyy
Copy link
Contributor

Still, someone has to have an access... Anyway, seems David has decided to post the script under his account, so it does not matter anymore ;)

@davidakachaos
Copy link
Contributor Author

I would be a better way to do it, but I wanted to start testing things out soon. Sorry if I made a mistake in that :-/

@berestovskyy
Copy link
Contributor

It's ok with me. We can always create another GitHub repo or a shared account on GreasyFork...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants