GithubHelp home page GithubHelp logo

elder-brother's Introduction

Hi there ๐Ÿ‘‹

elder-brother's People

Contributors

uuf6429 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

elder-brother's Issues

Better documentation

Come up with a better name and more useful documentation.

Things to note:

  • Not necessarily bound to git - all major vcs systems support hooks in one way or another
  • Not necessarily bound to composer - other systems might have a similar mechanism and/or devs can simply run the commands by themselves as applicable
  • = this system is not necessarily bound to git/composer.

Call PhpCsFixer directly

Instead of spawning php-cs-fixer for every file to be fixed, create a fixer instance, configure it and run it for the set of files to be fixed.
The main disadvantage is lack of isolation, but we can live with it.

Different approach for handling progress

Current approach is messy and too tied to the console.
Ideally, progress should be handled by one class, performing things like falling back to simple list / log approach etc.
Also, the current approach is a bit buggy depending on things like progress count etc.

Stub project for leaner deployment

Right now, if we want to force installation via composer scripts, the package has to be always required in composer, so one can't limit ElderBrother installation to just for developers.

This leaves the following options:

  • always require elder-brother package
  • always require a stub package which installs elder-brother if running in dev
  • create a complicated command (in composer script) that looks like:
    if (exists('/path/to/bin')) /path/to/bin install

Create a PhpCsFixer action

  • Will require PHP-CS-Fixer to be installed
  • Will expect list of files to be fixed (or otherwise will fix all files if null is specified)
  • Will use config file from project root unless overridden by argument

Example use:

new PhpCsFixer(glob('src/*.php'), 'cfg/.php_cs');

Avoid exceptions in actions

Use errors, warnings and notices instead of (Runtime|Recoverable) exceptions in actions.

This means:

  • at least one value object to contains the information
  • at least one buffer in action to contain items
  • ideally, items are printed when they are "logged" instead of when action finishes

Filter sql files by content

Using an sql parser, (eg; greenlion/PHP-SQL-Parser or phpmyadmin/sql-parser), extend FileList fluent interface with sql rules.

Usage Examples:

new ForbiddenFiles(
    $fileList
        ->name('*.sql')
        ->sqlWithDDL()
        ->sqlWithDML()
    ,
    'Mixing DML and DDL is not allowed.'
);
new ForbiddenFiles(
    $fileList
        ->name('*.sql')
        ->sqlWithDDL('CREATE TABLE')
        ->sqlWithDQL('SELECT')
    ,
    'Not allowed due to GTID being enabled.'
);
new RiskyFiles(
    $fileList
        ->name('*.sql')
        ->sqlWithDDL()
        ->sqlTable('products', 'users')
    ,
    'Possibly slow query that may block concurrent queries.'
);

A few proposed methods:

  • sqlWithDCL(...$allowedDCL)
  • sqlWithDDL(...$allowedDDL)
  • sqlWithDML(...$allowedDML)
  • sqlWithDQL(...$allowedDQL)
  • sqlWithDCL(...$allowedTCL)
  • sqlWithoutDCL(...$disallowedDCL)
  • sqlWithoutDDL(...$disallowedDDL)
  • sqlWithoutDML(...$disallowedDML)
  • sqlWithoutDQL(...$disallowedDQL)
  • sqlWithoutTCL(...$disallowedTCL)
  • sqlTable(...$allowedTables)
  • sqlNotTable(...$disallowedTables)
  • sqlFilter($callback($parsedSql))
  • sqlNotFilter($callback($parsedSql))

Decide on config file format

Rationale

The main reason why PHP could be used is that configuration can be easily written and documentation automatically provided through PHPDoc.

  • config syntax is checked automatically
  • documentation is automatically available
  • can provide native callbacks/expressions as configuration

What's missing?

  • Not much long-term thought about this mechanism
  • No structure (yet) for grouping actions by events
  • Find a reasonable way to merge the various config files (while loading) (note: user-level config overrides project-level)

Note: See PHP-CS-Fixer config for inspiration.

VCS hook (un)installer

Objective

Two commands for installing VCS (git, svn etc) hooks to point to this tool.

Notes

  • Maybe not all hooks should be installed? If so, use arguments to specify which
  • What should happen to any existing hooks? They should be at least backed up, but do we still call them?
  • The uninstall command should restore back any old hooks
  • The new hooks should be somehow marked so that running any of these commands twice does not produce an undesired effect

Document file finder

Document the various filtering methods in file finder.

  • Automatically generate documentation in README.md
  • Better document (eg, with examples) existing methods

Create an ExecuteCustomCode action

An action that takes a callback and executes it. The callback should receive $config and $output as arguments.

Example uses:

// named function
new ExecuteCustomCode(
    'doSomething'
);

// closure
new ExecuteCustomCode(
    function ($config, $output) { }
);

// static method
new ExecuteCustomCode(
    [\Vendor\Product\Something::class, 'doSomething']
);

// regular method
new ExecuteCustomCode(
    [new \Vendor\Product\Something(), 'doSomething']
);

Returning a non-falsy value should break the process. Throw an exception to break process.

Add more methods to changeset

Objective is to have most methods available in [symfony/finder] also available in changeset.
In particular: notName() and toIterator()

Create ExecuteProgram action

Usage:

new ExecuteProgram(
    '/usr/bin/php -f test.php',   // program to run
    '/home/user',                 // current directory (optional, default is project dir)
    true,                         // break on failure (optional, default is true)
)

Support multiple events

Action lists should be bound to an event. Ideally, events should be grouped by a type and the actual event, for example various git hooks would look like: git:pre-commit or git:commit-msg.

Reorganize FileList

  • Rename the main class to something more appropriate (eg; related to ExpressionBuilder)
  • Move related functionality into traits to decrease class complexity (similar to C# partial class)

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.