Skip to content

Commit 48ff15a

Browse files
MrDiverlgtm-migratornaveen521kk
authored
Codeql (#3084)
* Add CodeQL workflow for GitHub code scanning * fix codeql errors * ignore example scenes and tests Co-authored-by: LGTM Migrator <[email protected]> Co-authored-by: Naveen M K <[email protected]>
1 parent c34a8fb commit 48ff15a

File tree

5 files changed

+68
-6
lines changed

5 files changed

+68
-6
lines changed

.github/codeql.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
query-filters:
2+
- exclude:
3+
id: py/init-calls-subclass
4+
- exclude:
5+
id: py/unexpected-raise-in-special-method
6+
- exclude:
7+
id: py/modification-of-locals
8+
- exclude:
9+
id: py/multiple-calls-to-init
10+
- exclude:
11+
id: py/missing-call-to-init
12+
13+
paths:
14+
- manim
15+
paths-ignore:
16+
- tests/
17+
- example_scenes/

.github/workflows/codeql.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: "21 16 * * 3"
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ python ]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v2
31+
with:
32+
languages: ${{ matrix.language }}
33+
config-file: ./.github/codeql.yml
34+
queries: +security-and-quality
35+
36+
- name: Autobuild
37+
uses: github/codeql-action/autobuild@v2
38+
39+
- name: Perform CodeQL Analysis
40+
uses: github/codeql-action/analyze@v2
41+
with:
42+
category: "/language:${{ matrix.language }}"

manim/mobject/graph.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -627,13 +627,11 @@ def _create_vertex(
627627
f"Vertex identifier '{vertex}' is already used for a vertex in this graph.",
628628
)
629629

630-
if isinstance(label, (Mobject, OpenGLMobject)):
631-
label = label
632-
elif label is True:
630+
if label is True:
633631
label = MathTex(vertex, fill_color=label_fill_color)
634632
elif vertex in self._labels:
635633
label = self._labels[vertex]
636-
else:
634+
elif not isinstance(label, (Mobject, OpenGLMobject)):
637635
label = None
638636

639637
base_vertex_config = copy(self.default_vertex_config)

manim/mobject/text/text_mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def remove_invisible_chars(mobject: SVGMobject) -> SVGMobject:
9292
:class:`~.SVGMobject`
9393
The SVGMobject without unwanted invisible characters.
9494
"""
95-
95+
# TODO: Refactor needed
9696
iscode = False
9797
if mobject.__class__.__name__ == "Text":
9898
mobject = mobject[:]

manim/mobject/three_d/three_dimensions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,15 @@ def __init__(
124124
self.pre_function_handle_to_anchor_scale_factor = (
125125
pre_function_handle_to_anchor_scale_factor
126126
)
127-
self.func = func
127+
self._func = func
128128
self._setup_in_uv_space()
129129
self.apply_function(lambda p: func(p[0], p[1]))
130130
if self.should_make_jagged:
131131
self.make_jagged()
132132

133+
def func(self, u: float, v: float):
134+
return self._func(u, v)
135+
133136
def _get_u_values_and_v_values(self):
134137
res = tuplify(self.resolution)
135138
if len(res) == 1:
@@ -371,6 +374,8 @@ def __init__(
371374
res_value = (101, 51)
372375
elif config.renderer == RendererType.CAIRO:
373376
res_value = (24, 12)
377+
else:
378+
raise Exception("Unknown renderer")
374379

375380
resolution = resolution if resolution is not None else res_value
376381

0 commit comments

Comments
 (0)