GithubHelp home page GithubHelp logo

t-schroeder / moodle-cs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from moodlehq/moodle-cs

0.0 0.0 0.0 433 KB

Moodle Coding Style

Home Page: https://github.com/moodlehq/moodle-cs

License: GNU General Public License v3.0

PHP 100.00%

moodle-cs's Introduction

Moodle Coding Style

Latest Stable Version Release Date of the Latest Version

Unit Tests codecov

License Total Downloads Number of Contributors

Information

This repository contains the Moodle Coding Style configurations, written as PHP CodeSniffer rulesets.

Two coding styles are included:

  • moodle - the main ruleset for the Moodle Coding Style
  • moodle-extra - extended ruleset which includes recommended best practices
    • extends the main moodle ruleset

Currently this only includes the configuration for PHP Coding style, but this may be extended to include custom rules for JavaScript, and any other supported languages or syntaxes.

Installation

Using Composer (recommended)

You can install these coding style rules using Composer to make them available globally across your system.

This will install the correct version of phpcs, with the Moodle rules, and their dependencies.

composer global require moodlehq/moodle-cs

Configuration

Typically configuration is not required. Recent versions of Moodle (3.11 onwards) include a configuration file for the PHP CodeSniffer, which will set the standard when run within a Moodle directory.

Additional configuration can be generated automatically to have PHP CodeSniffer ignore any third-party library code. This can be generated by running:

npx grunt ignorefiles

Using the moodle-extra coding style

The recommended way of configuring PHP CodeSniffer to use the moodle-extra coding style is to provide an additional configuration file.

For Moodle 3.11 onwards you can create a file named .phpcs.xml with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
  <rule ref="./phpcs.xml"/>
  <rule ref="moodle-extra"/>
</ruleset>

This will load the phpcs.xml file (generated by npx grunt ignorefiles), and apply the moodle-extra configuration on top.

Moodle 3.10 and earlier

The easiset way to have PHP CodeSniffer pick up your preferred style, you can create a file named phpcs.xml with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
  <rule ref="moodle"/>
</ruleset>

If you wish to use the moodle-extra coding style, then you can use the following content:

<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
  <rule ref="moodle-extra"/>
</ruleset>

Note: Third-party library code will not be ignored with these versions of Moodle.

moodle-cs's People

Contributors

stronk7 avatar andrewnicols avatar timhunt avatar danpoltawski avatar junpataleta avatar sarjona avatar paulholden avatar kabalin avatar ankitagarwal avatar polothy avatar mudrd8mz avatar garemoko avatar brendanheywood avatar cameron1729 avatar roperto avatar golenkovm avatar peterburnett avatar ilyatregubov avatar sammarshallou avatar

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.