Skip to content

Commit b53d06e

Browse files
committed
Minor cleanup at 58% test coverage
Signed-off-by: John Rofrano <[email protected]>
1 parent f1de3d4 commit b53d06e

File tree

6 files changed

+86
-2
lines changed

6 files changed

+86
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Log file
66
*.log
77

8+
# Code coverage files
9+
.coverage
10+
811
# Gradle files
912
.gradle
1013

Makefile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Makefile targets for dvelopment an testing
2+
# Use make help for more info
3+
4+
.PHONY: help
5+
help: ## Display this help.
6+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
7+
8+
.PHONY: all
9+
all: help
10+
11+
##@ Development
12+
13+
.PHONY: venv
14+
venv: ## Create a Python virtual environment
15+
$(info Creating Python 3 virtual environment...)
16+
poetry shell
17+
18+
.PHONY: install
19+
install: ## Install Python dependencies in virtual environment
20+
$(info Installing dependencies...)
21+
poetry config virtualenvs.in-project true
22+
poetry install
23+
24+
.PHONY: lint
25+
lint: ## Run the linter
26+
$(info Running linting...)
27+
flake8 cldk --count --select=E9,F63,F7,F82 --show-source --statistics
28+
flake8 cldk --count --max-complexity=10 --max-line-length=180 --statistics
29+
pylint cldk --max-line-length=180
30+
31+
.PHONY: test
32+
test: ## Run the unit tests
33+
$(info Running tests...)
34+
pytest --pspec --cov=cldk --cov-fail-under=50 --disable-warnings
35+
36+
##@ Build
37+
38+
.PHONY: clean
39+
clean: ## Cleans up from previous compiles
40+
$(info Cleaning up compile artifacts...)
41+
rm -fr dist
42+
43+
.PHONY: refresh
44+
refresh: ## Refresh code analyzer
45+
$(info Refreshing CodeAnalyzer...)
46+
wget $(curl -s https://api.github.com/repos/IBM/codenet-minerva-code-analyzer/releases/latest | grep "browser_download_url" | grep codeanalyzer.jar | cut -d '"' -f 4)
47+
mv codeanalyzer.jar cldk/analysis/java/codeanalyzer/jar/codeanalyzer.jar
48+
49+
.PHONY: build
50+
build: ## Builds a new Python wheel
51+
$(info Building artifacts...)
52+
poetry build

cldk/analysis/javascript/treesitter/javascript_sitter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def __get_top_level_functions(self, code: str) -> List[JsCallable]:
184184

185185
query = """
186186
(program [
187-
(function_declaration) @function
187+
(function_declaration) @function
188188
(export_statement (function_declaration) @function.export)
189189
])
190190
"""
@@ -210,7 +210,7 @@ def __get_top_level_generators(self, code: str) -> List[JsCallable]:
210210

211211
query = """
212212
(program [
213-
(generator_function_declaration) @generator
213+
(generator_function_declaration) @generator
214214
(export_statement (generator_function_declaration) @generator.export)
215215
])
216216
"""

cldk/models/java/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ class JCallable(BaseModel):
184184
cyclomatic_complexity: int | None
185185

186186
def __hash__(self):
187+
"""
188+
Returns the hash value of the declaration.
189+
"""
187190
return hash(self.declaration)
188191

189192
@model_validator(mode="after")

setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Code Quality
2+
3+
[flake8]
4+
max-line-length = 180
5+
per-file-ignores =
6+
*/__init__.py: F401 E402

tests/tree_sitter/javascript/test_javascript_tree_sitter.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
################################################################################
2+
# Copyright IBM Corporation 2024
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
################################################################################
16+
17+
"""
18+
Javascript Treesitter Tests
19+
"""
20+
121
from typing import List
222

323
from unittest import TestCase

0 commit comments

Comments
 (0)