Coder Social home page Coder Social logo

sspooky13 / yaml-standards Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 2.0 399 KB

Standards for yaml files - adhere your yaml clean and nice

License: MIT License

PHP 97.78% Batchfile 0.03% JavaScript 0.12% Less 0.09% Dockerfile 1.31% Shell 0.67%
yaml standards indent alphabetical inline checker yaml-standards fixer yaml-files

yaml-standards's People

Contributors

boris-brtan avatar cafferata avatar chrisdbrown avatar petrheinz avatar sspooky13 avatar techi602 avatar tomasludvik avatar vasilvestre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

yaml-standards's Issues

indentation of comments before empty line

Which version(s) is affected: ^4.0.0

Description

Yaml standards don't work with new lines after comment. The suggest a change to remove all indentation before the comment. see Additional information

How to reproduce

Possible Solution

Additional information

eg. this:

    ObjectCalisthenics\Sniffs\Files\FunctionLengthSniff:
        maxLength: 60
        #sdkjfhsdkjfhsk

    ObjectCalisthenics\Sniffs\Metrics\PropertyPerClassLimitSniff:
        maxCount: 30

suggests this:

     ObjectCalisthenics\Sniffs\Files\FunctionLengthSniff:
         maxLength: 60
-        #sdkjfhsdkjfhsk
+#sdkjfhsdkjfhsk
 
     ObjectCalisthenics\Sniffs\Metrics\PropertyPerClassLimitSniff:
         maxCount: 30

New standard: Services: arguments are defined gradually or specifically

Description
Arguments can be defined in 2 ways: gradually or specifically. So, we should observe one way.

Example
Gradually

Foo\FooBundle\FooFacade:
    arguments:
        - '%arg_1%'
        - '%arg_2%'
        - '%arg_3%'

Specifically

Foo\FooBundle\FooFacade:
    arguments:
        $pathToDir: '%arg_1%'
        $pathToFile: '%arg_2%'
        $pathToImage: '%arg_3%'

Yaml indent checker: inconsistent indent for array

Which version(s) is affected: >3.1.0

Description
It should be space before dash in array, see example below. By yaml the code is valid but causes it inconsistent code because, it can be space before dash and may not be.

How to reproduce
Add e.g. one of this code to yaml file and check indent

foo:
-   foo: bar
    baz: qux
foo:
-   foo: bar

it should be space before dash

CI: add build PHP 8.2

Description
It will be great to add build app with PHP 8.2 to sure all works well

CI: build symfony 5 version

Which version(s) is affected: ^5.0

Description
Symfony 5 can't be built because shopsys/coding-standards locked symplify/easy-coding-standard to ^5 version and this version locked symfony to version ^3.4|^4.1
You can see in there https://travis-ci.org/sspooky13/yaml-standards/jobs/644890349

Possible Solution

  1. copy from easy-coding-standard.yml to this project and upgrade symplify/easy-coding-standard but I will have to upgrade easy-coding-standard.yml manually
  2. find other coding standards and use it but I am with shopsys/coding-standards yet satisfied ๐Ÿ˜
  3. create fork of shopsys/coding-standards and use it + create PR for upgrade

PHPParralelLint not installed

Which version(s) is affected: 4.0.0

Description
When installing as a dev dependency of another project PHPParralelLint is not included, as it is not defined in the composer file. Currently it's only included as it's a dependency of shopsys/coding-standards, so will only exist on dev installs.

How to reproduce

  1. Create new project with composer init
  2. composer require --dev sspooky13/yaml-standards
  3. Attempt to scan a directory, for example php vendor/bin/yaml-standards ./directory

You'll get the following error:
PHP Fatal error: Uncaught Error: Class 'JakubOnderka\PhpParallelLint\RecursiveDirectoryFilterIterator' not found in {project folder}/vendor/sspooky13/yaml-standards/src/Service/YamlFilesPathService.php:28

Possible Solution
Include this dependency in the composer file - will raise a PR for this shortly.

Additional information
Hope you don't mind me raising this - currently this is blocking me from using your tool on a personal project, so would be great to get this in. Do you mind me picking up some of the other issues on this repo if I've time after this is resolved?

add setHelp() for command

Description
add help description for yaml command but i don't know what I should write to it ๐Ÿ˜•

Example

// the full command description shown when running the command with
// the "--help" option
->setHelp('Any text that might be useful...')

make tests

Description
It would be great return and make new tests for methods.
Is recommended add coveralls.io into project.

allow build with lowest dependencies

Description
fix build in travis and appveyor for lowest dependencies

Example

environment:
  matrix:
#  - dependencies: lowest
#    php_version: 5.6
  - dependencies: highest
    php_version: 5.6
#  - dependencies: lowest
#    php_version: 7.0
  - dependencies: highest
    php_version: 7.0
#  - dependencies: lowest
#    php_version: 7.1
  - dependencies: highest
    php_version: 7.1
#  - dependencies: lowest
#    php_version: 7.2
  - dependencies: highest
    php_version: 7.2

CI: improve

Description

  • add and fix build PHP 7.4 in Travis and Appveyor so programmers know PHP 7.4 is really supported
  • at least to edit Travis for build every Symfony version

EDIT: I don't know how to simply build all Symfony versions so I skip it because it's not necessary to do it
EDIT2: I figured how to do it, so I maked it ๐Ÿ˜Š, done

Don't indent comment line ?

Hi,

I think, comment line should be ignored and not idented ?
For example :

framework:
    validation:
        email_validation_mode: html5

        # Enables validator auto-mapping support.
        # For instance, basic validation constraints will be inferred from Doctrine's metadata.
        #auto_mapping:
        #    App\Entity\: []

when@test:
    framework:
        validation:
            not_compromised_password: false

What do you think about that ?

Ty

glob() fails due GLOB_BRACE const usage, which is not available under alpine linux due non-standard libc (musl) usage

Which version(s) is affected: 8.0.0.

Description

Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38
Fatal error: Uncaught TypeError: glob() expects parameter 2 to be int, string given in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php:38

Full log

Warning: Use of undefined constant GLOB_BRACE - assumed 'GLOB_BRACE' (this will throw an Error in a future version of PHP) in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38

Fatal error: Uncaught TypeError: glob() expects parameter 2 to be int, string given in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php:38
Stack trace:
#0 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php(38): glob('./*{.yml,.yaml,...', 'GLOB_BRACE')
#1 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php(20): YamlStandards\Command\Service\FilesPathService::globRecursive('./*{.yml,.yaml,...')
#2 /srv/sylius/vendor/sspooky13/yaml-standards/src/Model/Config/YamlStandardConfigLoader.php(43): YamlStandards\Command\Service\FilesPathService::getPathToFiles(Array)
#3 /srv/sylius/vendor/sspooky13/yaml-standards/src/Model/Config/YamlStandardConfigLoader.php(31): YamlStandards\Model\Config\YamlStandardConfigLoader->createConfigData(Array)
#4 /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/YamlCommand.php(51): YamlStandards\Model\Config\YamlStandardConfigLoader->loadFromYaml('./yaml-standard...')
#5 /srv/sylius/vendor/symfo in /srv/sylius/vendor/sspooky13/yaml-standards/src/Command/Service/FilesPathService.php on line 38

How to reproduce
call yaml-standard bin from docker with alpine linux

Possible Solution

Handle possiblity of GLOB_BRACE missing.

https://www.php.net/manual/en/function.glob.php

image

Additional information
zendframework/zend-stdlib#58
zend-stdlib has fallback glob for this exact issue https://github.com/zendframework/zend-stdlib/blob/6d965efcce81ee60e2b425792f1cd3f27aed82d9/src/Glob.php#L39-L46

bad check/fix multidimensional array

Which version(s) is affected: all

Description
If you create multidimensional array without array key then checker/fixer don't work correctly

How to reproduce
e.g. this yaml

patchesJson6902:
-   target:
        group: extensions
        version: v1beta1
        kind: Ingress
        name: shopsys
    path: ./ingress-patch.yaml

checker/fixer want fix to this

patchesJson6902:
-   target:
        group: extensions
        version: v1beta1
        kind: Ingress
        name: shopsys
        path: ./ingress-patch.yaml

and it's incorrect.
See shopsys/shopsys#539 (comment) for better detail

create common classes for same used code

Description
make common classes (services) for same code is used in methods (e.g. is line a comment)

Example

protected function isCommentLine($fileLine)
{
    return preg_match('/^\s*#/', $fileLine) === 1;
}

Yaml path service: check file/dir exist before try to find files

Which version(s) is affected: maybe in all but will be fix in last one

Description
When it's path to non exists dir/file is defined then command write exception

Error was caught: RecursiveDirectoryIterator::__construct(/var/www/html/docker-sync.yml): failed to open dir: No such file or directory

Solution is check file/dir exists before run recursive check dirs

make tests for common classes

Description
If make sense then will be great to make tests for common classes, etc. command class to prevent not working application

Support PHP 8

Description
Add support version PHP 8

Alert
First #47 must be done

wrong indentation in arrays with unquoted values containing a colon

Which version(s) is affected: definitely v4.2.4, maybe older ones as well

Description

There is an issue with array item indentation. When an item is not quoted and contains a colon (:), it will have 3 spaces after a dash, even though it is not a nested array (might be caused by #27).

See Travis build of shopsys/demoshop for a real life example: https://travis-ci.org/shopsys/demoshop/builds/569339341#L4564-L4575

How to reproduce

Usual arrays (1 space after dash) โœ”๏ธ

array_name:
    - value
    - other value

Nested arrays (3 spaces after a dash) โœ”๏ธ

array name:
    -   key: value
        other key: value

Arrays with unquoted colons (3 spaces after a dash only when colon is present) โŒ

array_name:
    - value
    -   http://google.com
    - 'http://google.com'

Possible Solution

  1. fix the edge case to only force 3 spaces when the line is a proper key-value pair
  2. force 3 spaces (or more correctly n-1 where n is the indent count) on every array item line

Additional information

YAML apparently doesn't considers the line a key-value pair only if it is not in quoted string (eg. "key: value" will not be considered a key-value pair) and there is a space after the colon (eg. key: value or key : value but not key:value or key :value).

New standard: Services: unnecessary defined service

Description
Just idea, in services.yaml can be defined facade but it's not necessary because auto-wire load them, e.g.

Foo\BarBundle\:
        resource: '../../**/*{Facade}.php'

FooBarFacade: ~

, so it's not necessary that code exists in services.yaml and it can be removed

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.