Git Product home page Git Product logo

standards's Introduction

Vanilla's Coding Standards

This repo contains the Vanilla forums' coding standards utilities.

As explained in our documentation, our codebase is being updated to follow our standards. This is a long and ongoing process. Our codebase does not currently pass all the tests, but every new file added should!

You can use PHP_CodeSniffer to validate code using our coding standards. See Validating your PHP code with PHP_CodeSniffer from our documentation for more information.

standards's People

Contributors

charrondev avatar daazku avatar initvector avatar linc avatar tburry avatar dlacaille avatar r-j avatar

Watchers

James Cloos avatar TJ Webb avatar Sooraj Francis avatar Carla França avatar Patrick Kelly avatar Becky Van Bussel avatar Dan Redman avatar Kyle Nas avatar Jimmy Ghelani avatar Francis avatar Eric Vachaviolos avatar Alexander Kim avatar Richard Flynn avatar Alexei Pajitnov avatar  avatar Travis Nutting avatar Isis Graziatto avatar  avatar

Forkers

r-j isabella232

standards's Issues

Fix comment sniffs

We need to fix our custom comment sniffs.

The standard

Descriptions MUST BE a full sentence with a capital to start and period to end

Short, return and parameter descriptions MUST be included if present

There MUST be one space before and after parameters

What we are currently validating

  • The first line of the description can only be 1 line.
  • A long description MAY come after
  • Param annotations are REQUIRED for every parameter
  • A return annotation is REQUIRED no matter what.
  • There must be empty comment lines between [short description, long description, params, return].
  • You are not allowed to use the @see tag in a class comment. What is the purpose of this?

Acceptance Criteria

Sniff enforces ONLY the following on comments
There is a DocBlock on

  • A class
  • A method
  • A property

Enforce Code standards in CI

We should have CodeSniffer run on our changes in CI, so that PR's can be focused more on the code itself and the quality of the comments than on minor issues with the code.

Problems with FunctionCommentSniff: undefined index & faulty issues reported

Notice: Undefined index: in /git/standards/code-sniffer/Vanilla/Sniffs/Commenting/FunctionCommentSniff.php on line 196

Call Stack:
    0.0002     366816   1. {main}() /usr/local/Cellar/php71/7.1.3_15/bin/phpcs:0
    0.0103    1385960   2. PHP_CodeSniffer_CLI->runphpcs() /usr/local/Cellar/php71/7.1.3_15/bin/phpcs:25
    0.0107    1430864   3. PHP_CodeSniffer_CLI->process() /usr/local/Cellar/php71/7.1.3_15/lib/php/PHP/CodeSniffer/CLI.php:113
    0.0512    3333272   4. PHP_CodeSniffer->processFiles() /usr/local/Cellar/php71/7.1.3_15/lib/php/PHP/CodeSniffer/CLI.php:998
    2.6243    6548864   5. PHP_CodeSniffer->processFile() /usr/local/Cellar/php71/7.1.3_15/lib/php/PHP/CodeSniffer.php:653
    2.6244    6549008   6. PHP_CodeSniffer->_processFile() /usr/local/Cellar/php71/7.1.3_15/lib/php/PHP/CodeSniffer.php:1772
    2.6244    6549616   7. PHP_CodeSniffer_File->start() /usr/local/Cellar/php71/7.1.3_15/lib/php/PHP/CodeSniffer.php:1894
    2.6348    6770880   8. Vanilla_Sniffs_Commenting_FunctionCommentSniff->process() /usr/local/Cellar/php71/7.1.3_15/lib/php/PHP/CodeSniffer/File.php:576

Publish our standard to packagist

Our standard should be published to packagist so it can be more easily installed. This would also enable us to use it as a project dependency.

False positive on single blank line sniff

I'm finding that I'm getting the following error too much: "There must be a single blank line after the last param tag". There are a couple of cases when this is happening that I see:

  1. I have an @return tag.
  2. I have an @dataProvider tag.

The culprit seems to be in the FunctionCommentSniff. I think we can just get rid of this big if statement altogether.

Add additional lint rules

Trailing commas in arrays

There should be a built in sniff for this.

Spaces around the concat operator

There should be a built in sniff for this.

Spaces before and after various built in logic methods

  • for
  • if
  • foreach
  • etc

Update CodeSniffer standard for 2.0

See "Removal of the Comment Parser" here: https://www.squizlabs.com/php-codesniffer/2.0.0a1-released

[linc@derby community:master]# phpcs applications/addons/
PHP Fatal error:  Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found' in /git/addons/standards/Vanilla/Sniffs/Commenting/ClassCommentSniff.php:17
Stack trace:
#0 /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer.php(1324): include_once()
#1 /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer.php(560): PHP_CodeSniffer->registerSniffs(Array, Array)
#2 /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer/CLI.php(822): PHP_CodeSniffer->initStandard(Array, Array)
#3 /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer/CLI.php(95): PHP_CodeSniffer_CLI->process()
#4 /usr/local/Cellar/php-code-sniffer/2.4.0/scripts/phpcs(25): PHP_CodeSniffer_CLI->runphpcs()
#5 {main}
  thrown in /git/addons/standards/Vanilla/Sniffs/Commenting/ClassCommentSniff.php on line 17

Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found' in /git/addons/standards/Vanilla/Sniffs/Commenting/ClassCommentSniff.php on line 17

PHP_CodeSniffer_Exception: Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found in /git/addons/standards/Vanilla/Sniffs/Commenting/ClassCommentSniff.php on line 17

Call Stack:
    0.0004     241272   1. {main}() /usr/local/Cellar/php-code-sniffer/2.4.0/scripts/phpcs:0
    0.0084    1770768   2. PHP_CodeSniffer_CLI->runphpcs() /usr/local/Cellar/php-code-sniffer/2.4.0/scripts/phpcs:25
    0.0088    1836344   3. PHP_CodeSniffer_CLI->process() /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer/CLI.php:95
    0.0092    1854912   4. PHP_CodeSniffer->initStandard() /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer/CLI.php:822
    0.0184    1913712   5. PHP_CodeSniffer->registerSniffs() /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer.php:560
    0.0193    2073320   6. include_once('/git/addons/standards/Vanilla/Sniffs/Commenting/ClassCommentSniff.php') /usr/local/Cellar/php-code-sniffer/2.4.0/CodeSniffer.php:1324

Moved from vanilla/addons#282

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.