Embed Instructions

97.05% of the project's source code conforms to the same coding conventions

  • Image URL
    https://squizlabs.github.io/PHP_CodeSniffer/analysis/moodle/moodle/grade.svg
  • Markdown
    [![Code consistency](https://squizlabs.github.io/PHP_CodeSniffer/analysis/moodle/moodle/grade.svg)](https://squizlabs.github.io/PHP_CodeSniffer/analysis/moodle/moodle)
Aconsistency

Analysis of Coding Conventions for Moodle

PHP_CodeSniffer, using a custom coding standard and report, was used to record various coding conventions across 197 PHP projects.

Conventions

Analysis of Coding Conventions for Moodle

Back to top

View project specific report

Project
Consistency

Spacing after string concat

How many spaces follow the string concatenation operator?

This project is using the popular method for this convention

Current
Key Method Use
0 0 40.95%
1 - Most popular method 1 53.59%
2 2 0.11%
newline newline 5.35%

Based on 30,117 concat operators

Historical

Spacing before string concat

How many spaces precede the string concatenation operator?

This project is using the popular method for this convention

Current
Key Method Use
0 0 42.45%
1 - Most popular method 1 56.3%
newline newline 1.02%
Other other 0.23%

Based on 30,117 concat operators

Historical

Class defined in namespace

Is each class defined in a namespace of at least 1 level?

Current
Key Method Use
no - Most popular method no 59.49%
yes yes 40.51%

Based on 3,789 classes

Historical
  • 01 May 2016: there was a 3.68% swing from no to yes
  • 01 May 2018: there was a 5.35% swing from no to yes

Declarations and side effects mixed

Do files both declare symbols (classes, functions, constants, etc.) and cause side-effects (e.g. generate output, change .ini settings, etc.)?

Current
Key Method Use
no no 38.35%
yes - Most popular method yes 61.65%

Based on 5,025 files

Historical

Spacing after cast statement

How many spaces are there between a cast statement and the variable?

This project is using the popular method for this convention

Current
Key Method Use
0 - Most popular method 0 69.12%
1 1 30.88%

Based on 2,170 cast statements

Historical
  • 01 May 2016: there was a 4.59% swing from 0 to 1
  • 01 Nov 2016: there was a 3.14% swing from 0 to 1
  • 01 Jun 2018: there was a 3.46% swing from 0 to 1

Space before operator

How many spaces precede comparison, arithmetic and assignment operators?

This project is using the popular method for this convention

Current
Key Method Use
0 0 23.4%
1 - Most popular method 1 76.28%
Other other 0.32%

Based on 32,378 operators

Historical

Array end comma

Does the last item end with a comma in a multi-line array definition?

Current
Key Method Use
no - Most popular method no 77.48%
yes yes 22.52%

Based on 1,137 array definitions

Historical

Function has doc comment

Does each function have a docblock comment to describe its purpose?

This project is using the popular method for this convention

Current
Key Method Use
no no 21.23%
yes - Most popular method yes 78.77%

Based on 25,080 functions

Historical

One class per file

Is each class defined in a file by itself?

This project is using the popular method for this convention

Current
Key Method Use
no no 20.3%
yes - Most popular method yes 79.7%

Based on 3,789 classes

Historical

Adjacent assignments aligned

For a block of assignments, are the assignment operators (equals, plus-equals etc.) aligned?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 83.72%
yes yes 16.28%

Based on 25,645 assignment blocks

Historical

Number of newlines at EOF

How many newline characters appear at the end of the file?

This project is using the popular method for this convention

Current
Key Method Use
0 0 5.22%
1 - Most popular method 1 84.15%
2 2 7.32%
3 3 3.09%
Other other 0.22%

Based on 4,983 files

Historical

Private method prefixed with underscore

Are private methods prefixed with an underscore?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 85.68%
yes yes 14.32%

Based on 433 private methods

Historical

CamelCase method name

Are class method names defined using CamelCase?

Current
Key Method Use
no - Most popular method no 87.17%
yes yes 12.83%

Based on 21,526 methods

Historical

Short array syntax used

Are arrays defined using the PHP 5.4+ short array syntax?

Current
Key Method Use
no - Most popular method no 87.35%
yes yes 12.65%

Based on 36,208 array definitions

Historical

Class has doc comment

Does each class have a docblock comment to describe its purpose?

This project is using the popular method for this convention

Current
Key Method Use
no no 11.03%
yes - Most popular method yes 88.97%

Based on 3,789 classes

Historical

Line length

Including whitespace and comments, how many characters are in non-empty code lines?

This project is using the popular method for this convention

Current
Key Method Use
80 or less - Most popular method 80 or less 89.58%
81-120 81-120 9.28%
121-150 121-150 0.98%
151 or more 151 or more 0.17%

Based on 806,337 lines

Historical

Constant name case

What case are user-defined constants defined in?

This project is using the popular method for this convention

Current
Key Method Use
lower lower 7.74%
mixed mixed 1.11%
upper - Most popular method upper 91.15%

Based on 1,899 constants

Historical

Use of ELSE IF or ELSEIF

Are elseif statements defined using elseif or else if?

Current
Key Method Use
else if - Most popular method else if 93.47%
elseif elseif 6.53%

Based on 2,939 elseif statements

Historical

Space after operator

How many spaces follow comparison, arithmetic and assignment operators?

This project is using the popular method for this convention

Current
Key Method Use
0 0 3.26%
1 - Most popular method 1 96.44%
Other other 0.3%

Based on 213,612 operators

Historical

Blank lines at end of control structure

How many blank lines follow the body of a control structure?

This project is using the popular method for this convention

Current
Key Method Use
0 - Most popular method 0 97.46%
1 1 2.52%
2 2 0.02%

Based on 64,982 control structures

Historical

Blank lines at start of control structure

How many blank lines precede the body of a control structure?

This project is using the popular method for this convention

Current
Key Method Use
0 - Most popular method 0 98.26%
1 1 1.74%
2 2 0.01%

Based on 64,993 control structures

Historical

Function opening brace placement

Is the opening brace of a function on the same line as the function keyword or the next line?

Current
Key Method Use
new line new line 1.74%
same line - Most popular method same line 98.26%

Based on 24,524 functions

Historical

File has doc comment

Does each PHP file have a docblock comment to describe its purpose?

This project is using the popular method for this convention

Current
Key Method Use
no no 1.69%
yes - Most popular method yes 98.31%

Based on 5,025 files

Historical

Class opening brace placement

Is the opening brace of a class on the same line as the class keyword or the next line?

Current
Key Method Use
new line new line 1.58%
same line - Most popular method same line 98.42%

Based on 3,789 classes

Historical

Lowercase filename

Are PHP filenames lowercase?

Current
Key Method Use
no no 1.01%
yes - Most popular method yes 98.99%

Based on 5,025 files

Historical

PascalCase class name

Are class names defined using PascalCase?

Current
Key Method Use
no - Most popular method no 99.02%
yes yes 0.98%

Based on 3,789 classes

Historical

PHP constant case

What case are PHP constants (true, false, null) written in?

This project is using the popular method for this convention

Current
Key Method Use
lower - Most popular method lower 99.13%
upper upper 0.87%

Based on 30,604 PHP constants

Historical

Spaces before control structure close parenthesis

How many spaces precede the closing parenthesis of a control structure?

This project is using the popular method for this convention

Current
Key Method Use
0 - Most popular method 0 99.16%
1 1 0.83%
2 2 < 0.01%

Based on 56,025 control structures

Historical

Spaces after control structure open parenthesis

How many spaces follow the opening parenthesis of a control structure?

This project is using the popular method for this convention

Current
Key Method Use
0 - Most popular method 0 99.21%
1 1 0.78%
newline newline 0.01%

Based on 56,025 control structures

Historical

Control structure defined inline

Are control structures defined inline (without braces)?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 99.27%
yes yes 0.73%

Based on 64,791 control structures

Historical

PHP closing tag at EOF

Is there a PHP closing tag at the end of the file?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 99.38%
yes yes 0.62%

Based on 5,025 files

Historical

Line indent

Are lines indented using spaces or tabs?

This project is using the popular method for this convention

Current
Key Method Use
mixed mixed 0.11%
spaces - Most popular method spaces 99.46%
tabs tabs 0.44%

Based on 586,835 indented lines

Historical

Inline comment style

What comment style is used for non docblock comments?

This project is using the popular method for this convention

Current
Key Method Use
# ... # ... 0.04%
/* ... */ /* ... */ 0.3%
// ... - Most popular method // ... 99.65%

Based on 113,561 inline comments

Historical

EOL char

What character is used for line breaks?

This project is using the popular method for this convention

Current
Key Method Use
\n - Most popular method \n 99.9%
\r\n \r\n 0.1%

Based on 5,025 files

Historical

Spacing before object operator

How many spaces precede the object operator (->)?

This project is using the popular method for this convention

Current
Key Method Use
0 - Most popular method 0 99.91%
1 1 0.06%
newline newline 0.03%

Based on 215,285 object operators

Historical

Brackets around echoed strings

Are parenthesis placed around echo'd strings?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 99.91%
yes yes 0.09%

Based on 8,067 echo statements

Historical

PHP type case

What case are PHP types (int, bool, string) written in?

This project is using the popular method for this convention

Current
Key Method Use
lower - Most popular method lower 99.91%
mixed mixed 0.09%

Based on 3,488 PHP types

Historical

Spacing after object operator

How many spaces follow the object operator (->)?

This project is using the popular method for this convention

Current
Key Method Use
0 - Most popular method 0 99.93%
1 1 0.06%
newline newline 0.01%

Based on 215,285 object operators

Historical

Multiple statements on same line

Are multiple statements defined on the same line of code?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 99.95%
yes yes 0.05%

Based on 241,949 statements

Historical

Array keyword case

When defining an array, how is the array keyword written?

This project is using the popular method for this convention

Current
Key Method Use
lower - Most popular method lower 99.95%
mixed mixed 0.05%

Based on 31,628 array definitions

Historical

PHP keyword case

What case are PHP keywords (function, echo, foreach etc.) written in?

This project is using the popular method for this convention

Current
Key Method Use
lower - Most popular method lower 99.96%
mixed mixed 0.01%
upper upper 0.04%

Based on 289,361 keywords

Historical

CamelCase function name

Are global function names defined using CamelCase?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 100%

Based on 2,507 global functions

Historical

File extension for non-class files

For files that do not contain classes, what extension does the file use?

This project is using the popular method for this convention

Current
Key Method Use
.php - Most popular method .php 100%

Based on 2,005 non-class files

Historical

Closure opening brace placement

Is the opening brace of a closure on the same line as the function keyword or the next line?

This project is using the popular method for this convention

Current
Key Method Use
same line - Most popular method same line 100%

Based on 329 closures

Historical

PHP short open tag used

Is the PHP short open tag syntax used?

This project is using the popular method for this convention

Current
Key Method Use
no - Most popular method no 100%

Based on 8,041 open tags

Historical

File extension for class files

For files that contain classes, what extension does the file use?

This project is using the popular method for this convention

Current
Key Method Use
.php - Most popular method .php 100%

Based on 3,020 class files

Historical