Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
NOBUG: Adding travis (plugin) support
Adding travis support using the cool:

https://github.com/moodlerooms/moodle-plugin-ci

Plus minor fixes to make it pass.
  • Loading branch information
stronk7 committed Apr 2, 2016
1 parent aa020a6 commit bf3459b
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 55 deletions.
51 changes: 51 additions & 0 deletions .travis.yml
@@ -0,0 +1,51 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache

php:
- 5.4
- 7.0

env:
- MOODLE_BRANCH=master DB=pgsql IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs
- MOODLE_BRANCH=master DB=mysqli IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs
- MOODLE_BRANCH=MOODLE_30_STABLE DB=pgsql IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs
- MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs
- MOODLE_BRANCH=MOODLE_28_STABLE DB=pgsql IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs
- MOODLE_BRANCH=MOODLE_27_STABLE DB=mysqli IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs

matrix:
exclude:
- php: 7.0
env: MOODLE_BRANCH=MOODLE_27_STABLE DB=mysqli IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs
- php: 7.0
env: MOODLE_BRANCH=MOODLE_28_STABLE DB=pgsql IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs
- php: 7.0
env: MOODLE_BRANCH=MOODLE_29_STABLE DB=mysqli IGNORE_PATHS=moodle/tests/fixtures,moodle/Sniffs

before_install:
- phpenv config-rm xdebug.ini
- cd ../..
- composer selfupdate
- composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1
# - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci dev-master
- export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"

install:
- moodle-plugin-ci install

script:
- moodle-plugin-ci phplint
- moodle-plugin-ci phpcpd
- moodle-plugin-ci phpmd
- moodle-plugin-ci codechecker
- moodle-plugin-ci csslint
- moodle-plugin-ci shifter
- moodle-plugin-ci jshint
- moodle-plugin-ci validate
- moodle-plugin-ci phpunit
- moodle-plugin-ci behat
6 changes: 6 additions & 0 deletions CHANGES.md
@@ -1,3 +1,9 @@
Changes in version 2.5.3 (201604XX) - Another dent to indent
------------------------------------------------------------
- NOBUG: Add travis support (using the nice [moodle-plugin-ci](https://github.com/moodlerooms/moodle-plugin-ci)
assistant for Moodle plugins.
- ...

Changes in version 2.5.2 (20160314) - The March begins...
---------------------------------------------------------
- MDLSITE-4197: Allow backticks within lang strings. Valid Markdown.
Expand Down
2 changes: 2 additions & 0 deletions README.md
@@ -1,6 +1,8 @@
Moodle Code Checker
===================

[![Build Status](https://travis-ci.org/moodlehq/moodle-local_codechecker.svg?branch=master)](https://travis-ci.org/moodlehq/moodle-local_codechecker)

Information
-----------

Expand Down
8 changes: 7 additions & 1 deletion locallib.php
Expand Up @@ -60,7 +60,10 @@ protected function definition() {
}
}


// These classes are not following the moodle standard but phpcs one,
// so we intruct the checker to ignore them
// TODO: Move these classes to own php files.
// @codingStandardsIgnoreStart
/**
* Code sniffer insists on having an PHP_CodeSniffer_CLI, even though we don't
* really want one. This is a dummy class to make it work.
Expand Down Expand Up @@ -159,6 +162,9 @@ public function generateFileReport($report, PHP_CodeSniffer_File $phpcsFile, $sh
}
}

// End of phpcs classes, we end ignoring now.
// @codingStandardsIgnoreEnd

/**
* Convert a full path name to a relative one, for output.
* @param string $file a full path name of a file.
Expand Down
86 changes: 43 additions & 43 deletions moodle/tests/moodlestandard_test.php
Expand Up @@ -45,9 +45,9 @@ public function test_moodle_comenting_inlinecomment() {
$this->set_fixture(__DIR__ . '/fixtures/moodle_comenting_inlinecomment.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
4 => array('3 slashes comments are not allowed'),
6 => 1,
Expand Down Expand Up @@ -87,9 +87,9 @@ public function test_moodle_controlstructures_controlsignature() {
$this->set_fixture(__DIR__ . '/fixtures/moodle_controlstructures_controlsignature.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
3 => 0,
4 => array('found "if(...) {'),
Expand All @@ -109,9 +109,9 @@ public function test_generic_whitespace_disalowtabindent() {
$this->set_fixture(__DIR__ . '/fixtures/generic_whitespace_disallowtabindent.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
9 => 'Spaces must be used to indent lines; tabs are not allowed',
10 => 1,
Expand All @@ -131,9 +131,9 @@ public function test_generic_whitespace_scopeindent() {
$this->set_fixture(__DIR__ . '/fixtures/generic_whitespace_scopeindent.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
6 => 'indented incorrectly; expected at least 4 spaces, found 2 @Source: Generic.WhiteSpace.ScopeIndent.Incorrect',
18 => 'indented incorrectly; expected at least 4 spaces, found 2 @Source: Generic.WhiteSpace.ScopeIndent.Incorrect',
Expand All @@ -153,9 +153,9 @@ public function test_moodle_php_forbiddenfunctions() {
$this->set_fixture(__DIR__ . '/fixtures/moodle_php_forbiddenfunctions.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
5 => 'function sizeof() is forbidden; use count()',
6 => 1,
Expand All @@ -182,9 +182,9 @@ public function test_moodle_php_forbiddennamesasinvokedfunctions() {
$this->set_fixture(__DIR__ . '/fixtures/moodle_php_forbiddennamesasinvokedfunctions.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
5 => 0, // These are allowed as invoked functions in Moodle for now.
6 => 0,
Expand Down Expand Up @@ -218,9 +218,9 @@ public function test_moodle_php_forbiddentokens() {
$this->set_fixture(__DIR__ . '/fixtures/moodle_php_forbiddentokens.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
5 => 'The use of function eval() is forbidden',
6 => 'The use of operator goto is forbidden',
Expand All @@ -241,9 +241,9 @@ public function test_moodle_strings_forbiddenstrings() {
$this->set_fixture(__DIR__ . '/fixtures/moodle_strings_forbiddenstrings.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
8 => 'The use of the AS keyword to alias tables is bad for cross-db',
10 => 1,
Expand All @@ -268,17 +268,17 @@ public function test_moodle_strings_forbiddenstrings() {
/**
* Test external sniff incorporated to moodle standard.
*/
public function test_PHPCompatibility_php_deprecatedfunctions() {
public function test_phpcompatibility_php_deprecatedfunctions() {

// Define the standard, sniff and fixture to use.
$this->set_standard('moodle');
$this->set_sniff('PHPCompatibility.PHP.DeprecatedFunctions');
$this->set_fixture(__DIR__ . '/fixtures/PHPCompatibility_php_deprecatedfunctions.php');
$this->set_fixture(__DIR__ . '/fixtures/phpcompatibility_php_deprecatedfunctions.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array());
$this->set_warnings(array(
5 => array('function ereg_replace', 'use call_user_func instead', '@Source: PHPCompat')));
Expand All @@ -290,17 +290,17 @@ public function test_PHPCompatibility_php_deprecatedfunctions() {
/**
* Test call time pass by reference.
*/
public function test_PHPCompatibility_php_forbiddencalltimepassbyreference() {
public function test_phpcompatibility_php_forbiddencalltimepassbyreference() {

// Define the standard, sniff and fixture to use.
$this->set_standard('moodle');
$this->set_sniff('PHPCompatibility.PHP.ForbiddenCallTimePassByReference');
$this->set_fixture(__DIR__ . '/fixtures/PHPCompatibility_php_forbiddencalltimepassbyreference.php');
$this->set_fixture(__DIR__ . '/fixtures/phpcompatibility_php_forbiddencalltimepassbyreference.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
6 => array('call-time pass-by-reference is prohibited'),
7 => array('@Source: PHPCompat')));
Expand All @@ -321,9 +321,9 @@ public function test_moodle_namingconventions_variablename() {
$this->set_fixture(__DIR__ . '/fixtures/moodle_namingconventions_variablename.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
4 => 'must not contain underscores',
5 => 'must be all lower-case',
Expand Down Expand Up @@ -358,9 +358,9 @@ public function test_moodle_operator_spacing() {
$this->set_fixture(__DIR__ . '/fixtures/squiz_whitespace_operatorspacing.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array(
5 => 0,
6 => 'Expected 1 space before',
Expand Down Expand Up @@ -424,9 +424,9 @@ public function test_squid_php_commentedoutcode() {
$this->set_fixture(__DIR__ . '/fixtures/squiz_php_commentedoutcode.php');

// Define expected results (errors and warnings). Format, array of:
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
// - line => number of problems, or
// - line => array of contents for message / source problem matching.
// - line => string of contents for message / source problem matching (only 1).
$this->set_errors(array());
$this->set_warnings(array(
5 => 'This comment is 63% valid code; is this commented out code',
Expand Down
12 changes: 7 additions & 5 deletions renderer.php
Expand Up @@ -210,11 +210,13 @@ public function problem_message($problem, $prettypath) {
if ($lastfileandline !== $prettypath . '#@#' . $line) {
// We have moved to another line, output it.
$code = html_writer::tag('li', html_writer::tag('div',
html_writer::tag('pre', '#' . $line . ': ' . str_replace(
array_keys($this->replaces),
array_values($this->replaces),
s(local_codechecker_get_line_of_code($line, $prettypath)))
)), array('class' => 'sourcecode'));
html_writer::tag('pre', '#' . $line . ': ' . str_replace(
array_keys($this->replaces),
array_values($this->replaces),
s(local_codechecker_get_line_of_code($line, $prettypath))
))),
array('class' => 'sourcecode')
);
$lastfileandline = $prettypath . '#@#' . $line;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/behat/ui.feature
Expand Up @@ -18,8 +18,8 @@ Feature: Codechecker UI works as expected
Examples:
| path | seen | notseen |
| index.php | Files found: 1 | Invalid path |
| index.php | Well done! | Invalid path |
| index2.php | Invalid path index2.php | Files found: 1 |
| local/codechecker/version.php | Well done! | Invalid path |
| local/codechecker/moodle/tests/fixtures | Files found: 0 | Invalid path |
| local/codechecker/tests/ | local_codechecker_testcase.php | Invalid path |
| local/codechecker/tests/ | Files found: 1 | Invalid path |
Expand Down Expand Up @@ -47,9 +47,9 @@ Feature: Codechecker UI works as expected
| local/codechecker/moodle/tests | */tests/fixtures/* | moodlestandard_test.php | Invalid path |
| local/codechecker/moodle/tests/ | *PHPC*, *moodle_* | Files found: 5 | Invalid path |
| local/codechecker/moodle/tests/ | *PHPC*, *moodle_* | Line 1 of the opening comment | moodle_php |
| local/codechecker/moodle/tests/ | *PHPC*, *moodle_* | Inline comments must end | /PHPCompat |
| local/codechecker/moodle/tests/ | *PHPC*, *moodle_* | Inline comments must end | /PHPCompat |
| local/codechecker/moodle/tests/ | *moodle_* | fixtures/PHPCompat | /moodle_php |
| local/codechecker/moodle/tests/ | *PHPC*, *moodle_* | Inline comments must end | /phpcompat |
| local/codechecker/moodle/tests/ | *PHPC*, *moodle_* | Inline comments must end | /phpcompat |
| local/codechecker/moodle/tests/ | *moodle_* | fixtures/phpcompat | /moodle_php |

# We use the @javascript tag here because of MDL-53083, causing non-javascript to fail unchecking checkboxes
@javascript
Expand Down
16 changes: 16 additions & 0 deletions thirdpartylibs.xml
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<libraries>
<library>
<location>pear</location>
<name>PHP_CodeSniffer</name>
<version>pre 2.6.0 (8c5d176)</version>
<license>BSD 3-Clause</license>
</library>
<library>
<location>PHPCompatibility</location>
<name>PHP Compatibility Coding Standard</name>
<version>(1becdd2)</version>
<license>LGPL</license>
<licenseversion>3</licenseversion>
</library>
</libraries>
4 changes: 2 additions & 2 deletions version.php
Expand Up @@ -24,8 +24,8 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2016031400;
$plugin->release = '2.5.2';
$plugin->version = 2016040200;
$plugin->release = '2.5.2+';
$plugin->maturity = MATURITY_STABLE;
$plugin->requires = 2014051200; // Moodle 2.7 release and upwards.
$plugin->component = 'local_codechecker';

0 comments on commit bf3459b

Please sign in to comment.