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

No Auto Generated Themes #65

Merged
merged 1 commit into from Dec 19, 2016
Merged

No Auto Generated Themes #65

merged 1 commit into from Dec 19, 2016

Conversation

khacoder
Copy link
Contributor

Issue #63
Verify that themes are not generated, by searching for strings contained in known auto generated packages.

@grappler
Copy link
Member

This looks good. It will need an update to pass the automated tests.

@grappler grappler force-pushed the feature/theme-review-sniffs branch 2 times, most recently from 563cd1d to 6671823 Compare September 27, 2016 12:28
@grappler
Copy link
Member

grappler commented Oct 1, 2016

I have rebased the branch so that it is up to date with the latest code and this get's travis to run it's latest checks. To update the branch locally run git reset origin/feature/no-auto-generate --hard

@grappler
Copy link
Member

The PR is ready for the final review. I have simplified the checks to only check for the names. When downloading the latest version of the generated themes I did not find the code that the check was looking for. These are not common words so there should not be any problem with false possitives.

* @category PHP
* @package PHP_CodeSniffer
* @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/
*/
Copy link

Choose a reason for hiding this comment

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

Please update the doc block to comply with the current standards.

return;
}

$generated_themes = array(
Copy link

Choose a reason for hiding this comment

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

This should be a class property, similar to the include/require sniff class property.

'wpthemegenerator',
);

foreach ( $generated_themes as $generated_theme ) {
Copy link

Choose a reason for hiding this comment

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

Similar to the favicon one, we could probably use a regex here, though as it's only four strings being sniffed for, it's not a breaking issue at the moment.
If/when the list gets longer, I would very much suggest changing it to a regex.


foreach ( $generated_themes as $generated_theme ) {
if ( false !== strpos( strtolower( $token['content'] ), $generated_theme ) ) {
$phpcsFile->addError( 'Auto generated themes are not allowed in the theme directory.', $stackPtr, 'AutoGeneratedFound' );
Copy link

Choose a reason for hiding this comment

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

Maybe add a Found: %s to the error sentence ? Or is this left out on purpose ?

// wpthemegenerator.com
/*
* @package templatetoaster
*/
Copy link

Choose a reason for hiding this comment

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

As you are sniffing for both PHP as well as CSS, you will need a css example file too and deal with that in the unit test file.

// TemplateToaster.
'templatetoaster',
// WP Theme Generator.
'wpthemegenerator',
Copy link

Choose a reason for hiding this comment

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

Looks like the list has become a lot shorter than it originally was. Should the other snippets no longer be sniffed for ? How will they be dealt with ?

Copy link
Member

Choose a reason for hiding this comment

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

I mentioned in the comment above:

When downloading the latest version of the generated themes I did not find the code that the check was looking for.

Copy link

Choose a reason for hiding this comment

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

Ah, I misread that comment before.

Still, serial theme builders often don't download a new version of base code for each theme (take TGMPA for example... sigh...), so should we may be still check for code from at least a few versions back ?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be a big problem any more. This was a bigger problem a few years ago. As we have been blocking the generators spammers should know by no they are not allowed.

Copy link

Choose a reason for hiding this comment

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

You and the other members of the TRT are the better judge of that. I just wonder if relaxing the sniffs will not make some of them think "hang on, now we have a chance again...."

@@ -0,0 +1,11 @@

<p>Lubith</p>

Copy link

Choose a reason for hiding this comment

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

Are these "real life" examples or made up examples ? I would very much prefer to see real life examples here to demonstrate what is being sniffed for and how.

Also, let's add some examples to make sure we don't get false positives.

@grappler
Copy link
Member

We need to add https://pinegrow.com/wordpress-theme-builder.html to the list.
Example of theme build with it: https://themes.svn.wordpress.org/dokumentasi-template/1.0/

@grappler
Copy link
Member

@jrfnl I have made the requested changes. Thank you for pushing me use real world examples. Found a few bugs that way. Once I get the greenlight I can squash the commits.

Copy link

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

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

Looking good!
Two points remaining:

  • the file doc block at the top of the unit test file (see previous review)
  • adding some test data to make sure we won't get false positives.

@grappler
Copy link
Member

I have updated file doc block. Do you have any ideas for test data to make sure we do not get false positives. I can't think of any. The keywords are unique enough that normal users should not be using them.

The only idea that I had was to split the keywords up so that they were normal words. e.g. artist, them, template, toaster, pine, grow, theme, wp

@jrfnl
Copy link

jrfnl commented Dec 19, 2016

Do you have any ideas for test data to make sure we do not get false positives. I can't think of any. The keywords are unique enough that normal users should not be using them.

Just some random thoughts on this:

  1. CSS - add a header or two or ok themes (twentyseventeen and a non-automattic ok theme)
  2. Add some lines containing things like: artisteers, wpthemler, glubith

Does that help ?

2 => 1,
3 => 1,
6 => 1,
6 => 1,
Copy link

Choose a reason for hiding this comment

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

Looks like there is a duplicate line here

Issue #63
Verify that themes are not generated, by searching for strings contained in known auto generated packages.
@grappler
Copy link
Member

Fixed the last bug. There is a chance for false positives if a theme uses any of the restricted words but the chances and reasons to do so it is very low.

@jrfnl jrfnl merged commit 13e9146 into WPTT:feature/theme-review-sniffs Dec 19, 2016
@grappler grappler deleted the feature/no-auto-generate branch December 19, 2016 22:50
@jrfnl jrfnl added this to the 0.1.0 milestone Aug 20, 2018
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.

None yet

3 participants