|
| 1 | +#!/usr/bin/bash |
| 2 | + |
| 3 | +FILEPATH='.' |
| 4 | +perform_linting () { |
| 5 | + if [[ $FILEPATH == '.' ]] |
| 6 | + then |
| 7 | + pylint -j 4 --rcfile=.pylintrc ./core |
| 8 | + pylint -j 4 --rcfile=.pylintrc ./core/parsing |
| 9 | + pylint -j 4 --rcfile=.pylintrc ./tests/example |
| 10 | + pylint -j 4 --rcfile=.pylintrc ./tests/example/sample_component |
| 11 | + pylint -j 4 --rcfile=.pylintrc ./tests/functional |
| 12 | + pylint -j 4 --rcfile=.pylintrc ./tests/functional/glusterd |
| 13 | + pylint -j 4 --rcfile=.pylintrc ./support |
| 14 | + pylint -j 4 --rcfile=.pylintrc ./support/ops/gluster_ops |
| 15 | + pylint -j 4 --rcfile=.pylintrc ./support/ops/support_ops |
| 16 | + else |
| 17 | + pylint -j 4 --rcfile=.pylintrc $FILEPATH |
| 18 | + fi |
| 19 | +} |
| 20 | + |
| 21 | +help_info () { |
| 22 | +# Provides the help information |
| 23 | +# Describes the flags and their usage |
| 24 | + echo |
| 25 | + echo "Linting help" |
| 26 | + echo "=============" |
| 27 | + echo "Flags:" |
| 28 | + echo "-p : Specifies the path of the file" |
| 29 | + echo " Ex: tools/linting.sh -p /home/redant/core" |
| 30 | + echo |
| 31 | + echo "-f : Specifies flake operation to be performed only" |
| 32 | + echo " Ex: If you want to test flake for core" |
| 33 | + echo " tools/linting.sh -p /home/redant/core -f" |
| 34 | + echo |
| 35 | + echo "-l : Specifies lint operation to be performed only" |
| 36 | + echo " Ex: If you want to test lint for core" |
| 37 | + echo " tools/linting.sh -p /home/redant/core -l" |
| 38 | + echo |
| 39 | + echo "-h : Provides the information about the flags" |
| 40 | + echo |
| 41 | + echo "Note:" |
| 42 | + echo "=====" |
| 43 | + echo "If you don't specify the path, the operation will occur on the whole repo" |
| 44 | + echo |
| 45 | + echo "Ex: tools/linting.sh -f -l" |
| 46 | + echo "This will perform the linting on the whole repo" |
| 47 | + echo |
| 48 | + echo "Examples:" |
| 49 | + echo "=========" |
| 50 | + echo "tools/linting.sh -f" |
| 51 | + echo "This will perform only flake on the folder" |
| 52 | + echo |
| 53 | + echo "tools/linting.sh -l" |
| 54 | + echo "This will perform only lint on the folder" |
| 55 | + echo |
| 56 | + echo "tools/linting.sh -p /home/redant/core -f -l" |
| 57 | + echo "This will perform linting on the folder" |
| 58 | + echo |
| 59 | + echo "tools/linting.sh -p /home/redant/core -f" |
| 60 | + echo "This will perform only flake operation on the folder" |
| 61 | + echo |
| 62 | + echo "tools/linting.sh -p /home/redant/core -l" |
| 63 | + echo "This will perform only lint operation on the folder" |
| 64 | + echo |
| 65 | + echo "tools/linting.sh -[wrong flag]" |
| 66 | + echo "This will show illegal action" |
| 67 | +} |
| 68 | + |
| 69 | +while getopts "p:flh" opt; do |
| 70 | + case $opt in |
| 71 | + p) |
| 72 | + if [[ $OPTARG == '' ]] |
| 73 | + then |
| 74 | + echo "No path specified." |
| 75 | + echo "Linting the whole repo" |
| 76 | + else |
| 77 | + echo "Path File:"$OPTARG |
| 78 | + FILEPATH=$OPTARG |
| 79 | + fi |
| 80 | + ;; |
| 81 | + f) |
| 82 | + echo "Flake operation starts" |
| 83 | + flake8 $FILEPATH |
| 84 | + ;; |
| 85 | + l) |
| 86 | + echo "Lint operation starts" |
| 87 | + perform_linting |
| 88 | + ;; |
| 89 | + h) |
| 90 | + help_info |
| 91 | + |
| 92 | + ;; |
| 93 | + \?) |
| 94 | + help_info |
| 95 | + |
| 96 | + ;; |
| 97 | + esac |
| 98 | +done |
0 commit comments