Git Product home page Git Product logo

lifterlms-cs's Introduction

LifterLMS Coding Standards

LifterLMS Coding Standards (LifterLMS-CS) is a project with rulesets for code style and quality intended for use in LifterLMS projects.

Installation

To include in a project require as a development dependency:

composer require lifterlms/lifterlms-cs:dev-trunk --dev

If you are upgrading from the old version, be sure to remove any references to manually setting the installed_pathsas they are now automatically set by Composer.

Using PHPCS & PHPCBF

Access the PHPCS execultable via: ./vendor/bin/phpcs Check for errors only: ./vendor/bin/phpcs --error-severity=1 --warning-severity=6 Fix errors via PHPCBF: ./vendor/bin/phpcbf

Predefined scripts

The following scripts can be added to your composer.json file for easy access to thes scripts & to ensure configurations are automatically set during package installation and updates.

"scripts": {
    "check-cs": [
        "\"vendor/bin/phpcs\" --colors"
    ],
    "check-cs-errors": [
        "\"vendor/bin/phpcs\" --colors --error-severity=1 --warning-severity=6"
    ],
    "fix-cs": [
        "\"vendor/bin/phpcbf\""
    ]
}

Developing LifterLMS-CS

To include in a project and make changes to the LifterLMS-CS project itself:

Add to your composer.json file with the @dev tag and reference your local copy of this repository in the repositories block:

"require-dev": {
    "lifterlms/lifterlms-cs": "@dev"
},
"repositories": [
    {
        "type": "path",
        "url": "/absolute/path/to/lifterlms-cs"
    }
]

lifterlms-cs's People

Contributors

brianhogg avatar eri-trabiccolo avatar github-actions[bot] avatar pondermatic avatar thomasplevy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lifterlms-cs's Issues

Allow Direct DB Queries and usage of `meta_key` and `meta_value`?

There's some rules that we nearly always ignore. Should we remove these rules at the library level so as to not require always ignoring rules we're simply okay with using?

These rules could be disabled:
WordPress.DB.DirectDatabaseQuery.DirectQuery
WordPress.DB.SlowDBQuery.slow_db_query_meta_key
WordPress.DB.SlowDBQuery.slow_db_query_meta_value
WordPress.DB.SlowDBQuery.slow_db_query_meta_query
WordPress.DB.SlowDBQuery.slow_db_query_tax_query

I think we should keep the DB caching rule to help us remember to use cashing where possilbe:
WordPress.DB.DirectDatabaseQuery.NoCaching

No files are checked if path contains "wordpress"

Reproduction Steps

If the path to LifterLMS contains wordpress, then no files are checked. In my development environment, the path is C:\Vistacast\WordPress\src\wp-content\plugins\lifterlms\.

Files are checked if lifterlms-cs/LifterLMS/ruleset.xml is changed.

-    <exclude-pattern>wordpress/*</exclude-pattern>
+    <exclude-pattern>^/wordpress/*</exclude-pattern>

Expected Behavior

$ vendor/bin/phpcs -v
Registering sniffs in the LifterLMS Core standard... DONE (257 sniffs registered)
Creating file list... DONE (744 files in queue)
...

Actual Behavior

$ vendor/bin/phpcs -v
Registering sniffs in the LifterLMS Core standard... DONE (257 sniffs registered)
Creating file list... DONE (0 files in queue)

System and Environment Information

Windows 10
PHP 7.4

This issue has be recreated:

  • Locally
  • On a staging site
  • On a production website
  • With only LifterLMS and a default theme

exclude-pattern improvements

Is your feature request related to a problem? Please describe.
No.

Describe the solutions you'd like

  1. Exclude all minimized JavaScript files, not just the ones is the normal assets/js/ directory.
    -    <exclude-pattern>assets/js/*.min.js</exclude-pattern>
    +    <exclude-pattern>*.min.js</exclude-pattern>
  2. Only exclude these directories if they are at the top-level path that is being filtered.
    -    <exclude-pattern>tests/*</exclude-pattern>
    +    <exclude-pattern type="relative">^tests/*</exclude-pattern>
    -    <exclude-pattern>tmp/*</exclude-pattern>
    +    <exclude-pattern type="relative">^tmp/*</exclude-pattern>
    -    <exclude-pattern>gulpfile.js/*</exclude-pattern>
    +    <exclude-pattern type="relative">^gulpfile.js/*</exclude-pattern>
  3. Limit the pattern to directories with a specific name. ./vendor/ vs. ./prefix-vendor/
    -    <exclude-pattern>vendor/*</exclude-pattern>
    +    <exclude-pattern>*/vendor/*</exclude-pattern>
    -    <exclude-pattern>node_modules/*</exclude-pattern>
    +    <exclude-pattern>*/node_modules/*</exclude-pattern>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.