GithubHelp home page GithubHelp logo

itma / codechecker Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 2 KB

A simple php class to check whether a given application source code contains unwanted strings etc.

PHP 100.00%
codereview codechecker php unstablecode phpclass phpconsole

codechecker's Introduction

The Basic Goal

The basic goal is to avoid pushing messy source code into a repository and makes a developer sure that before the code goes to a test or production environment, it is free from any problem causing strings.

How To Use The Class

Pull the class on your local machine. Then configure it as below:

// Create an instance of the code checker
$codeChecker = new \itma\code\Checker();

// Set the path to grep through 
$codeChecker->path = '/your/path/to/source/code/';

// Skip these pathes
$codeChecker->exclude = [
    '/your/path/to/source/code/vendor/lib/',
];

// Disallowed words
$codeChecker->strings = [
    '1==0',
    '1== 0',
    '1 ==0',
    '1 == 0',
    '0 == 1',
    '0==1',
    '0 ==1',
    '0== 1',
    'print_r',
    'var_dump',
    '& false',
    '& true',
    'if(true)',
    'if( true )',
    'if( true)',
    'if(true )',
    'if(false)',
    'if( false )',
    'if( false)',
    'if(false )',
    'if (true)',
    'if ( true )',
    'if ( true)',
    'if (true )',
    'if (false)',
    'if ( false )',
    'if ( false)',
    'if (false )',
    'dupa',
    'debug_backtrace',
];

// Check!
echo $codeChecker->check();

Run the command as it is showed below (remember to use the path you actually placed the file with the class):

dev@dev:$ php codechecker.php

The result you will get should be similar to the below:



The list of words with numbers
==================================

String: 1==0 appears 0 times.
String: 1== 0 appears 0 times.
String: 1 ==0 appears 0 times.
String: 1 == 0 appears 4 times.
String: 0 == 1 appears 0 times.
String: 0==1 appears 0 times.
String: 0 ==1 appears 0 times.
String: 0== 1 appears 0 times.
String: print_r appears 35 times.
String: var_dump appears 59 times.
String: & false appears 0 times.
String: & true appears 6 times.
String: if(true) appears 3 times.
String: if( true ) appears 0 times.
String: if( true) appears 0 times.
String: if(true ) appears 0 times.
String: if(false) appears 0 times.
String: if( false ) appears 0 times.
String: if( false) appears 0 times.
String: if(false ) appears 0 times.
String: if (true) appears 6 times.
String: if ( true ) appears 0 times.
String: if ( true) appears 0 times.
String: if (true ) appears 0 times.
String: if (false) appears 0 times.
String: if ( false ) appears 0 times.
String: if ( false) appears 0 times.
String: if (false ) appears 0 times.
String: dupa appears 0 times.
String: debug_backtrace appears 6 times.

The list of files containing disallowed words:
==================================

==================================
1 == 0
==================================
/your/path/to/source/code/file.php
/your/path/to/source/code/class.php

codechecker's People

Stargazers

 avatar

Watchers

 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.