eqator


Nameeqator JSON
Version 2.7.0 PyPI version JSON
download
home_pagehttps://github.com/garpixcms/eqator
SummaryChecking the Django project for quality
upload_time2023-04-06 12:53:21
maintainer
docs_urlNone
authorGarpix LTD
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # eqator

Checking the Django project for quality. It can be convenient if you include it in CI.

Used packages: 

* [django unittest](https://docs.djangoproject.com/en/3.1/topics/testing/overview/) - unit testing in Django.
* [flake8](https://pypi.org/project/flake8/) - linter of source code.
* [radon](https://pypi.org/project/radon/) - tool that computes various metrics from the source code.
* [bandit](https://pypi.org/project/bandit/) - a security linter from PyCQA.
* [coverage](https://pypi.org/project/coverage/) - a test coverage for unittest.

## Quickstart

Install with pip:

```bash
pip install eqator
```

Add the `eqator` to your `INSTALLED_APPS`:

```python
# settings.py

INSTALLED_APPS = [
    # ...
    'eqator',
]
```

To use Lighthouse scoring, install `Lighthouse CI` with `npm`:

```bash
npm install -g @lhci/cli
```

Check your project:

```bash
python manage.py qa
```


Check your project by separate options.

Run checking style guide with flake8:

```bash
python manage.py qa -f
```

```bash
python manage.py qa --flake
```

Run checking cyclomatic complexity with radon

```bash
python manage.py qa -r
```

```bash
python manage.py qa --radon
```

Run security lint with bandit

```bash
python manage.py qa -l
```

```bash
python manage.py qa --linter
```

Run django project migrations check

```bash
python manage.py qa -m
```

```bash
python manage.py qa --migrations
```

Run django unittest

```bash
python manage.py qa -t
```

```bash
python manage.py qa --tests
```

Run django unit tests for garpix_page

```bash
python manage.py qa -p
```

```bash
python manage.py qa --garpix_page
```

Lighthouse CI check:

(requires Lighthouse CI installed)

```bash
python manage.py qa -lh
```

```bash
python manage.py qa --lighthouse
```

Run test coverage check

```bash
python manage.py qa -c
```

```bash
python manage.py qa --test_coverage
```

Note, that you need to add `TEST_COVERAGE_RATE` variable to your `settings.py` file (default value is 70):

```python
TEST_COVERAGE_RATE = 70
```

Optionally, do not save Lighthouse CI report files:

```bash
python manage.py qa --all --clear-reports
```

Check your project with all logs:

```bash
python manage.py qa --verbose
```

You can also add add `SENTRY_CHECK_METHOD` and `LIGHTHOUSE_CHECK_METHOD` variables to your `settings.py` file to controle the sentry SDK and lighthouse CI checking methods:

```python
# settings.py
SENTRY_CHECK_METHOD = 'error'
LIGHTHOUSE_CHECK_METHOD = 'warning'
```


### Example output with OK

```
Input

  Directory: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend
  Start at: 2021-02-27 12:09:30.999142

Checking

  Checking style guide with flake8 (see ".flake8") OK
  Django unit tests OK
  Cyclomatic complexity with radon (see "radon.cfg") OK
  Security lint with bandit (only high-severity issues, see ".bandit") OK

Result

  Problems found: 0
  End at: 2021-02-27 12:09:33.789880
  Duration: 0:00:02.790738

```

### Example output with problems

```
Input

  Directory: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend
  Start at: 2021-02-27 12:23:41.066752

Checking

  Checking style guide with flake8 (see ".flake8") ERROR
/Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/constants.py:18:4: W292 no newline at end of file
/Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/helpers.py:38:1: E302 expected 2 blank lines, found 1
/Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/colors.py:9:1: W391 blank line at end of file

  Django unit tests OK
  Cyclomatic complexity with radon (see "radon.cfg") OK
  Security lint with bandit (only high-severity issues, see ".bandit") ERROR
[main]  INFO    Found project level .bandit file: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/.bandit
[main]  INFO    profile include tests: None
[main]  INFO    cli include tests: None
[main]  INFO    cli exclude tests: None
[main]  INFO    running on Python 3.8.2
Run started:2021-02-27 12:23:45.044503

Test results:
>> Issue: [B602:subprocess_popen_with_shell_equals_true] subprocess call with shell=True identified, security issue.
   Severity: High   Confidence: High
   Location: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/helpers.py:39
   More Info: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html
38      def shell_run(cmd):
39          ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
40          lines = ps.communicate()[0]

--------------------------------------------------
Code scanned:
        Total lines of code: 285
        Total lines skipped (#nosec): 0

Run metrics:
        Total issues (by severity):
                Undefined: 0.0
                Low: 1.0
                Medium: 0.0
                High: 1.0
        Total issues (by confidence):
                Undefined: 0.0
                Low: 0.0
                Medium: 0.0
                High: 2.0
Files skipped (0):


Result

  Problems found: 2
  End at: 2021-02-27 12:23:45.098015
  Duration: 0:00:04.031263

```

## Configure Lighthouse CI
Edit `lighthouserc.json` to set URL and configure assertions. 

Reference: https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md

## Configure TestCase unit tests
Edit `testcaserc.json` to add configure options.

All available configurations:

- `apps` - list of apps must be tested;
- `keepdb` - preserves the test DB between runs;
- `top_level` - top level of project for unittest discovery;
- `pattern` - the test matching pattern. Defaults to test*.py;
- `reverse` - reverses test cases order;
- `debug_sql` - sets settings.DEBUG to True;
- `parallel` - run tests using up to N parallel processes;
- `tags` - run only tests with the specified tag;
- `exclude_tags` - do not run tests with the specified tag;
- `pdb` - runs a debugger (pdb, or ipdb if installed) on error or failure;
- `buffer` - discard output from passing tests;
- `test_name_patterns` - Only run test methods and classes that match the pattern or substring

Example:

```json
{
    "apps": ["app"],
}
```

## Send report

To send statistics you need to add `EQATOR_SEND_HOST`:
```python
# settings.py

EQATOR_SEND_HOST = 'http://example.com/analytics/eqator/:project_name/'
```

```bash
python manage.py qa --send
```

Data format

```json
{
  "duration": "0:00:01.557757",
  "start_at": "2022-09-20 11:56:41.230550",
  "error_count": 4,
  "flake_count": 2,
  "radon_count": 1,
  "sentry_count": 0,
  "coverage_value": 8,
  "coverage_result": 0,
  "lighthouse_count": 0,
  "migrations_count": 1,
  "unit_tests_count": 0,
  "security_linter_count": 0,
  "garpix_page_tests_count": 0
}
```


# Changelog

See [CHANGELOG.md](CHANGELOG.md).

# Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md).

# License

[MIT](LICENSE)

---

Developed by Garpix / [https://garpix.com](https://garpix.com)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/garpixcms/eqator",
    "name": "eqator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Garpix LTD",
    "author_email": "info@garpix.com",
    "download_url": "https://files.pythonhosted.org/packages/b0/1e/493c4b38353c42e2f28b36dbc16f872b486ea7377fab62ea37acc6c0238e/eqator-2.7.0.tar.gz",
    "platform": null,
    "description": "# eqator\n\nChecking the Django project for quality. It can be convenient if you include it in CI.\n\nUsed packages: \n\n* [django unittest](https://docs.djangoproject.com/en/3.1/topics/testing/overview/) - unit testing in Django.\n* [flake8](https://pypi.org/project/flake8/) - linter of source code.\n* [radon](https://pypi.org/project/radon/) - tool that computes various metrics from the source code.\n* [bandit](https://pypi.org/project/bandit/) - a security linter from PyCQA.\n* [coverage](https://pypi.org/project/coverage/) - a test coverage for unittest.\n\n## Quickstart\n\nInstall with pip:\n\n```bash\npip install eqator\n```\n\nAdd the `eqator` to your `INSTALLED_APPS`:\n\n```python\n# settings.py\n\nINSTALLED_APPS = [\n    # ...\n    'eqator',\n]\n```\n\nTo use Lighthouse scoring, install `Lighthouse CI` with `npm`:\n\n```bash\nnpm install -g @lhci/cli\n```\n\nCheck your project:\n\n```bash\npython manage.py qa\n```\n\n\nCheck your project by separate options.\n\nRun checking style guide with flake8:\n\n```bash\npython manage.py qa -f\n```\n\n```bash\npython manage.py qa --flake\n```\n\nRun checking cyclomatic complexity with radon\n\n```bash\npython manage.py qa -r\n```\n\n```bash\npython manage.py qa --radon\n```\n\nRun security lint with bandit\n\n```bash\npython manage.py qa -l\n```\n\n```bash\npython manage.py qa --linter\n```\n\nRun django project migrations check\n\n```bash\npython manage.py qa -m\n```\n\n```bash\npython manage.py qa --migrations\n```\n\nRun django unittest\n\n```bash\npython manage.py qa -t\n```\n\n```bash\npython manage.py qa --tests\n```\n\nRun django unit tests for garpix_page\n\n```bash\npython manage.py qa -p\n```\n\n```bash\npython manage.py qa --garpix_page\n```\n\nLighthouse CI check:\n\n(requires Lighthouse CI installed)\n\n```bash\npython manage.py qa -lh\n```\n\n```bash\npython manage.py qa --lighthouse\n```\n\nRun test coverage check\n\n```bash\npython manage.py qa -c\n```\n\n```bash\npython manage.py qa --test_coverage\n```\n\nNote, that you need to add `TEST_COVERAGE_RATE` variable to your `settings.py` file (default value is 70):\n\n```python\nTEST_COVERAGE_RATE = 70\n```\n\nOptionally, do not save Lighthouse CI report files:\n\n```bash\npython manage.py qa --all --clear-reports\n```\n\nCheck your project with all logs:\n\n```bash\npython manage.py qa --verbose\n```\n\nYou can also add add `SENTRY_CHECK_METHOD` and `LIGHTHOUSE_CHECK_METHOD` variables to your `settings.py` file to controle the sentry SDK and lighthouse CI checking methods:\n\n```python\n# settings.py\nSENTRY_CHECK_METHOD = 'error'\nLIGHTHOUSE_CHECK_METHOD = 'warning'\n```\n\n\n### Example output with OK\n\n```\nInput\n\n  Directory: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend\n  Start at: 2021-02-27 12:09:30.999142\n\nChecking\n\n  Checking style guide with flake8 (see \".flake8\") OK\n  Django unit tests OK\n  Cyclomatic complexity with radon (see \"radon.cfg\") OK\n  Security lint with bandit (only high-severity issues, see \".bandit\") OK\n\nResult\n\n  Problems found: 0\n  End at: 2021-02-27 12:09:33.789880\n  Duration: 0:00:02.790738\n\n```\n\n### Example output with problems\n\n```\nInput\n\n  Directory: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend\n  Start at: 2021-02-27 12:23:41.066752\n\nChecking\n\n  Checking style guide with flake8 (see \".flake8\") ERROR\n/Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/constants.py:18:4: W292 no newline at end of file\n/Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/helpers.py:38:1: E302 expected 2 blank lines, found 1\n/Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/colors.py:9:1: W391 blank line at end of file\n\n  Django unit tests OK\n  Cyclomatic complexity with radon (see \"radon.cfg\") OK\n  Security lint with bandit (only high-severity issues, see \".bandit\") ERROR\n[main]  INFO    Found project level .bandit file: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/.bandit\n[main]  INFO    profile include tests: None\n[main]  INFO    cli include tests: None\n[main]  INFO    cli exclude tests: None\n[main]  INFO    running on Python 3.8.2\nRun started:2021-02-27 12:23:45.044503\n\nTest results:\n>> Issue: [B602:subprocess_popen_with_shell_equals_true] subprocess call with shell=True identified, security issue.\n   Severity: High   Confidence: High\n   Location: /Users/aleksejkuznecov/projects/garpix_packages/eqator/backend/eqator/helpers.py:39\n   More Info: https://bandit.readthedocs.io/en/latest/plugins/b602_subprocess_popen_with_shell_equals_true.html\n38      def shell_run(cmd):\n39          ps = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\n40          lines = ps.communicate()[0]\n\n--------------------------------------------------\nCode scanned:\n        Total lines of code: 285\n        Total lines skipped (#nosec): 0\n\nRun metrics:\n        Total issues (by severity):\n                Undefined: 0.0\n                Low: 1.0\n                Medium: 0.0\n                High: 1.0\n        Total issues (by confidence):\n                Undefined: 0.0\n                Low: 0.0\n                Medium: 0.0\n                High: 2.0\nFiles skipped (0):\n\n\nResult\n\n  Problems found: 2\n  End at: 2021-02-27 12:23:45.098015\n  Duration: 0:00:04.031263\n\n```\n\n## Configure Lighthouse CI\nEdit `lighthouserc.json` to set URL and configure assertions. \n\nReference: https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md\n\n## Configure TestCase unit tests\nEdit `testcaserc.json` to add configure options.\n\nAll available configurations:\n\n- `apps` - list of apps must be tested;\n- `keepdb` - preserves the test DB between runs;\n- `top_level` - top level of project for unittest discovery;\n- `pattern` - the test matching pattern. Defaults to test*.py;\n- `reverse` - reverses test cases order;\n- `debug_sql` - sets settings.DEBUG to True;\n- `parallel` - run tests using up to N parallel processes;\n- `tags` - run only tests with the specified tag;\n- `exclude_tags` - do not run tests with the specified tag;\n- `pdb` - runs a debugger (pdb, or ipdb if installed) on error or failure;\n- `buffer` - discard output from passing tests;\n- `test_name_patterns` - Only run test methods and classes that match the pattern or substring\n\nExample:\n\n```json\n{\n    \"apps\": [\"app\"],\n}\n```\n\n## Send report\n\nTo send statistics you need to add `EQATOR_SEND_HOST`:\n```python\n# settings.py\n\nEQATOR_SEND_HOST = 'http://example.com/analytics/eqator/:project_name/'\n```\n\n```bash\npython manage.py qa --send\n```\n\nData format\n\n```json\n{\n  \"duration\": \"0:00:01.557757\",\n  \"start_at\": \"2022-09-20 11:56:41.230550\",\n  \"error_count\": 4,\n  \"flake_count\": 2,\n  \"radon_count\": 1,\n  \"sentry_count\": 0,\n  \"coverage_value\": 8,\n  \"coverage_result\": 0,\n  \"lighthouse_count\": 0,\n  \"migrations_count\": 1,\n  \"unit_tests_count\": 0,\n  \"security_linter_count\": 0,\n  \"garpix_page_tests_count\": 0\n}\n```\n\n\n# Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md).\n\n# Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n# License\n\n[MIT](LICENSE)\n\n---\n\nDeveloped by Garpix / [https://garpix.com](https://garpix.com)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Checking the Django project for quality",
    "version": "2.7.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6967c0caf828ba72fc66ce2d2c9b594bdc8bdf91f103be6cf08a398ece58ac79",
                "md5": "50f7baa5fbe09166c4a45ee5b1caabf3",
                "sha256": "d32aea73b0a55e454e2ec60d85c0c2e6fcae5bac22831fc3f2dcbf8a58bc7077"
            },
            "downloads": -1,
            "filename": "eqator-2.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "50f7baa5fbe09166c4a45ee5b1caabf3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 25786,
            "upload_time": "2023-04-06T12:53:18",
            "upload_time_iso_8601": "2023-04-06T12:53:18.757007Z",
            "url": "https://files.pythonhosted.org/packages/69/67/c0caf828ba72fc66ce2d2c9b594bdc8bdf91f103be6cf08a398ece58ac79/eqator-2.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b01e493c4b38353c42e2f28b36dbc16f872b486ea7377fab62ea37acc6c0238e",
                "md5": "e1367d752eeeb4715627c64796829c72",
                "sha256": "9ccbca22a9b90b3982b0230f29f61d829edea06a158c6419c9ad53e0bc993af7"
            },
            "downloads": -1,
            "filename": "eqator-2.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e1367d752eeeb4715627c64796829c72",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 19045,
            "upload_time": "2023-04-06T12:53:21",
            "upload_time_iso_8601": "2023-04-06T12:53:21.201877Z",
            "url": "https://files.pythonhosted.org/packages/b0/1e/493c4b38353c42e2f28b36dbc16f872b486ea7377fab62ea37acc6c0238e/eqator-2.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-06 12:53:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "garpixcms",
    "github_project": "eqator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "eqator"
}
        
Elapsed time: 0.05317s