Skip to content

Commit 06c89ec

Browse files
committed
merging 2.2 and develop
1 parent 2547088 commit 06c89ec

File tree

1,649 files changed

+251638
-160731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,649 files changed

+251638
-160731
lines changed

.bandit

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
# B406 : import_xml_sax
77
# B410 : import_lxml
88
skips: B101,B102,B320,B404,B406,B410
9+
exclude: **/tests/**,tests

.coveragerc

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ branch = true
44

55
source =
66
cvat/apps/
7-
utils/cli/
7+
cvat-sdk/
8+
cvat-cli/
89
utils/dataset_manifest
910

1011
omit =

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
/db.sqlite3
88
/keys
99
**/node_modules
10-
10+
/static

.eslintrc.js

+58-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,72 @@
1-
// Copyright (C) 2018-2021 Intel Corporation
1+
// Copyright (C) 2018-2022 Intel Corporation
22
//
33
// SPDX-License-Identifier: MIT
44

55
module.exports = {
6+
root: true,
67
env: {
78
node: true,
89
browser: true,
9-
es6: true,
10+
es2020: true,
1011
},
1112
parserOptions: {
1213
sourceType: 'module',
13-
ecmaVersion: 2018,
14+
parser: '@typescript-eslint/parser',
1415
},
15-
plugins: ['eslint-plugin-header'],
16-
extends: ['eslint:recommended', 'prettier'],
16+
ignorePatterns: [
17+
'.eslintrc.js',
18+
'lint-staged.config.js',
19+
],
20+
plugins: ['@typescript-eslint', 'security', 'no-unsanitized', 'import'],
21+
extends: [
22+
'eslint:recommended', 'plugin:security/recommended', 'plugin:no-unsanitized/DOM',
23+
'airbnb-base', 'plugin:import/errors', 'plugin:import/warnings',
24+
'plugin:import/typescript', 'plugin:@typescript-eslint/recommended', 'airbnb-typescript/base',
25+
],
1726
rules: {
18-
'header/header': [2, 'line', [{
19-
pattern: ' {1}Copyright \\(C\\) (?:20\\d{2}-)?2021 Intel Corporation',
20-
template: ' Copyright (C) 2021 Intel Corporation'
21-
}, '', ' SPDX-License-Identifier: MIT']],
27+
// 'header/header': [2, 'line', [{
28+
// pattern: ' {1}Copyright \\(C\\) (?:20\\d{2}-)?2022 Intel Corporation',
29+
// template: ' Copyright (C) 2022 Intel Corporation'
30+
// }, '', ' SPDX-License-Identifier: MIT']],
31+
'no-plusplus': 0,
32+
'no-continue': 0,
33+
'no-console': 0,
34+
'no-param-reassign': ['error', { 'props': false }],
35+
'no-restricted-syntax': [0, { selector: 'ForOfStatement' }],
36+
'no-await-in-loop': 0,
37+
'indent': ['error', 4, { 'SwitchCase': 1 }],
38+
'max-len': ['error', { code: 120, ignoreStrings: true }],
39+
'func-names': 0,
40+
'valid-typeof': 0,
41+
'no-useless-constructor': 0, // sometimes constructor is necessary to generate right documentation in cvat-core
42+
'quotes': ['error', 'single'],
43+
'lines-between-class-members': 0,
44+
'class-methods-use-this': 0,
45+
'no-underscore-dangle': ['error', { allowAfterThis: true }],
46+
'max-classes-per-file': 0,
47+
'operator-linebreak': ['error', 'after'],
48+
'newline-per-chained-call': 0,
49+
'global-require': 0,
50+
'arrow-parens': ['error', 'always'],
51+
'security/detect-object-injection': 0, // the rule is relevant for user input data on the node.js environment
52+
'import/order': ['error', {'groups': ['builtin', 'external', 'internal']}],
53+
'import/prefer-default-export': 0, // works incorrect with interfaces
54+
55+
'@typescript-eslint/ban-ts-comment': 0,
56+
'@typescript-eslint/no-explicit-any': 0,
57+
'@typescript-eslint/indent': ['error', 4],
58+
'@typescript-eslint/lines-between-class-members': 0,
59+
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
60+
'@typescript-eslint/explicit-module-boundary-types': 'off',
61+
'@typescript-eslint/ban-types': [
62+
'error',
63+
{
64+
types: {
65+
'{}': false, // TODO: try to fix with Record<string, unknown>
66+
object: false, // TODO: try to fix with Record<string, unknown>
67+
Function: false, // TODO: try to fix somehow
68+
},
69+
},
70+
],
2271
},
2372
};

.github/ISSUE_TEMPLATE.md

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
<!---
2-
Copyright (C) 2020 Intel Corporation
3-
4-
SPDX-License-Identifier: MIT
5-
-->
6-
71
### My actions before raising this issue
8-
- [ ] Read/searched [the docs](https://github.com/opencv/cvat/tree/master#documentation)
2+
- [ ] Read/searched [the docs](https://github.com/cvat-ai/cvat/tree/master#documentation)
93
- [ ] Searched [past issues](/issues)
104

115
<!--- Provide a general summary of the issue in the Title above -->
@@ -24,7 +18,7 @@ current behavior -->
2418
to implement the addition or change -->
2519

2620
### Steps to Reproduce (for bugs)
27-
<!--- Provide a link to a live example, or an unambiguous set of steps to
21+
<!--- Provide a link to a live example or an unambiguous set of steps to
2822
reproduce this bug. Include code to reproduce, if relevant -->
2923
1.
3024
1.
@@ -49,5 +43,3 @@ the bug in -->
4943
<summary>Logs from `cvat` container</summary>
5044
</details>
5145

52-
### Next steps
53-
You may [join our Gitter](https://gitter.im/opencv-cvat/public) channel for community support.

.github/PULL_REQUEST_TEMPLATE.md

+10-22
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
<!---
2-
Copyright (C) 2020-2021 Intel Corporation
3-
4-
SPDX-License-Identifier: MIT
5-
-->
6-
7-
<!-- Raised an issue to propose your change (https://github.com/opencv/cvat/issues).
8-
It will help avoiding duplication of efforts from multiple independent contributors.
1+
<!-- Raised an issue to propose your change (https://github.com/cvat-ai/cvat/issues).
2+
It helps to avoid duplication of efforts from multiple independent contributors.
93
Discuss your ideas with maintainers to be sure that changes will be approved and merged.
10-
Read the [CONTRIBUTION](https://github.com/opencv/cvat/blob/develop/CONTRIBUTING.md)
4+
Read the [CONTRIBUTION](https://github.com/cvat-ai/cvat/blob/develop/CONTRIBUTING.md)
115
guide. -->
126

137
<!-- Provide a general summary of your changes in the Title above -->
@@ -25,27 +19,21 @@ see how your change affects other areas of the code, etc. -->
2519
### Checklist
2620
<!-- Go over all the following points, and put an `x` in all the boxes that apply.
2721
If an item isn't applicable by a reason then ~~explicitly strikethrough~~ the whole
28-
line. If you don't do that github will show incorrect process for the pull request.
22+
line. If you don't do that github will show an incorrect process for the pull request.
2923
If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
3024
- [ ] I submit my changes into the `develop` branch
31-
- [ ] I have added description of my changes into [CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md) file
25+
- [ ] I have added a description of my changes into [CHANGELOG](https://github.com/cvat-ai/cvat/blob/develop/CHANGELOG.md) file
3226
- [ ] I have updated the [documentation](
33-
https://github.com/opencv/cvat/blob/develop/README.md#documentation) accordingly
27+
https://github.com/cvat-ai/cvat/blob/develop/README.md#documentation) accordingly
3428
- [ ] I have added tests to cover my changes
3529
- [ ] I have linked related issues ([read github docs](
3630
https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
37-
- [ ] I have increased versions of npm packages if it is necessary ([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),
38-
[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning), [cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning) and [cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))
31+
- [ ] I have increased versions of npm packages if it is necessary ([cvat-canvas](https://github.com/cvat-ai/cvat/tree/develop/cvat-canvas#versioning),
32+
[cvat-core](https://github.com/cvat-ai/cvat/tree/develop/cvat-core#versioning), [cvat-data](https://github.com/cvat-ai/cvat/tree/develop/cvat-data#versioning) and [cvat-ui](https://github.com/cvat-ai/cvat/tree/develop/cvat-ui#versioning))
3933

4034
### License
4135

4236
- [ ] I submit _my code changes_ under the same [MIT License](
43-
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the project.
37+
https://github.com/cvat-ai/cvat/blob/develop/LICENSE) that covers the project.
4438
Feel free to contact the maintainers if that's a concern.
45-
- [ ] I have updated the license header for each file (see an example below)
46-
47-
```python
48-
# Copyright (C) 2021 Intel Corporation
49-
#
50-
# SPDX-License-Identifier: MIT
51-
```
39+

.github/workflows/bandit.yml

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
1-
name: Linter
1+
name: Bandit
22
on: pull_request
33
jobs:
4-
Bandit:
4+
Linter:
55
runs-on: ubuntu-latest
66
steps:
7-
- uses: actions/checkout@v2
7+
- uses: actions/checkout@v3
8+
- id: files
9+
uses: jitterbit/get-changed-files@v1
10+
continue-on-error: true
811

912
- name: Run checks
13+
env:
14+
PR_FILES_AM: ${{ steps.files.outputs.added_modified }}
15+
PR_FILES_RENAMED: ${{ steps.files.outputs.renamed }}
1016
run: |
11-
URL="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files"
12-
PR_FILES=$(curl -s -X GET -G $URL | jq -r '.[] | select(.status != "removed") | .filename')
13-
for files in $PR_FILES; do
14-
extension="${files##*.}"
15-
if [[ $extension == 'py' ]]; then
16-
changed_files_bandit+=" ${files}"
17-
fi
17+
PR_FILES="$PR_FILES_AM $PR_FILES_RENAMED"
18+
for FILE in $PR_FILES; do
19+
EXTENSION="${FILE##*.}"
20+
DIRECTORY="${FILE%%/*}"
21+
if [[ "$EXTENSION" == 'py' && "$DIRECTORY" != 'cvat-sdk' ]]; then
22+
CHANGED_FILES+=" $FILE"
23+
fi
1824
done
1925
20-
if [[ ! -z ${changed_files_bandit} ]]; then
26+
if [[ ! -z $CHANGED_FILES ]]; then
2127
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
2228
python3 -m venv .env
2329
. .env/bin/activate
2430
pip install -U pip wheel setuptools
2531
pip install bandit
2632
mkdir -p bandit_report
2733
28-
echo "Bandit version: "`bandit --version | head -1`
29-
echo "The files will be checked: "`echo ${changed_files_bandit}`
30-
bandit ${changed_files_bandit} --exclude '**/tests/**' -a file --ini ./.bandit -f html -o ./bandit_report/bandit_checks.html
34+
echo "Bandit version: "$(bandit --version | head -1)
35+
echo "The files will be checked: "$(echo $CHANGED_FILES)
36+
bandit -a file --ini .bandit -f html -o ./bandit_report/bandit_checks.html $CHANGED_FILES
3137
deactivate
3238
else
3339
echo "No files with the \"py\" extension found"
3440
fi
3541
3642
- name: Upload artifacts
3743
if: failure()
38-
uses: actions/upload-artifact@v2
44+
uses: actions/upload-artifact@v3.1.1
3945
with:
4046
name: bandit_report
4147
path: bandit_report

.github/workflows/black.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Black
2+
on: pull_request
3+
jobs:
4+
Linter:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v3
8+
- id: files
9+
uses: jitterbit/get-changed-files@v1
10+
continue-on-error: true
11+
12+
- name: Run checks
13+
env:
14+
PR_FILES_AM: ${{ steps.files.outputs.added_modified }}
15+
PR_FILES_RENAMED: ${{ steps.files.outputs.renamed }}
16+
run: |
17+
# If different modules use different Black configs,
18+
# we need to run Black for each python component group separately.
19+
# Otherwise, they all will use the same config.
20+
ENABLED_DIRS=("cvat-sdk" "cvat-cli" "tests/python")
21+
22+
isValueIn () {
23+
# Checks if a value is in an array
24+
# https://stackoverflow.com/a/8574392
25+
# args: value, array
26+
local e match="$1"
27+
shift
28+
for e; do
29+
[[ "$e" == "$match" ]] && return 0;
30+
done
31+
return 1
32+
}
33+
34+
startswith () {
35+
# Inspired by https://stackoverflow.com/a/2172367
36+
# Checks if the first arg starts with the second one
37+
local value="$1"
38+
local beginning="$2"
39+
return $([[ $value == ${beginning}* ]])
40+
}
41+
42+
PR_FILES="$PR_FILES_AM $PR_FILES_RENAMED"
43+
UPDATED_DIRS=""
44+
for FILE in $PR_FILES; do
45+
EXTENSION="${FILE##*.}"
46+
DIRECTORY="$(dirname $FILE)"
47+
if [[ "$EXTENSION" == "py" ]]; then
48+
for EDIR in ${ENABLED_DIRS[@]}; do
49+
if startswith "${DIRECTORY}/" "${EDIR}/" && ! isValueIn "${EDIR}" ${UPDATED_DIRS[@]};
50+
then
51+
UPDATED_DIRS+=" ${EDIR}"
52+
fi
53+
done
54+
fi
55+
done
56+
57+
if [[ ! -z $UPDATED_DIRS ]]; then
58+
sudo apt-get --no-install-recommends install -y build-essential curl python3-dev python3-pip python3-venv
59+
python3 -m venv .env
60+
. .env/bin/activate
61+
pip install -U pip wheel setuptools
62+
pip install $(egrep "black.*" ./cvat-cli/requirements/development.txt)
63+
mkdir -p black_report
64+
65+
echo "Black version: "$(black --version)
66+
echo "The dirs will be checked: $UPDATED_DIRS"
67+
EXIT_CODE=0
68+
for DIR in $UPDATED_DIRS; do
69+
black --check --diff $DIR >> ./black_report/black_checks.txt || EXIT_CODE=$(($? | $EXIT_CODE)) || true
70+
done
71+
deactivate
72+
exit $EXIT_CODE
73+
else
74+
echo "No files with the \"py\" extension found"
75+
fi
76+
77+
- name: Upload artifacts
78+
if: failure()
79+
uses: actions/[email protected]
80+
with:
81+
name: black_report
82+
path: black_report

0 commit comments

Comments
 (0)