codinsight 0.1.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. codinsight-0.3.0/PKG-INFO +108 -0
  2. codinsight-0.3.0/README.md +91 -0
  3. codinsight-0.3.0/pyproject.toml +56 -0
  4. {codinsight-0.1.0 → codinsight-0.3.0}/setup.cfg +4 -4
  5. codinsight-0.3.0/src/code_insight/__init__.py +57 -0
  6. codinsight-0.3.0/src/code_insight/code_analysis/abstract.py +91 -0
  7. codinsight-0.3.0/src/code_insight/code_analysis/algorithm.py +442 -0
  8. codinsight-0.3.0/src/code_insight/code_analysis/complexity.py +402 -0
  9. codinsight-0.3.0/src/code_insight/code_analysis/quality.py +409 -0
  10. codinsight-0.3.0/src/code_insight/code_analysis/readability.py +540 -0
  11. codinsight-0.3.0/src/code_insight/code_analysis/redundancy.py +341 -0
  12. codinsight-0.3.0/src/code_insight/code_analysis/security.py +327 -0
  13. codinsight-0.3.0/src/code_insight/code_analysis/struct.py +586 -0
  14. codinsight-0.3.0/src/code_insight/code_analysis/style.py +237 -0
  15. codinsight-0.3.0/src/code_insight/core.py +219 -0
  16. codinsight-0.3.0/src/code_insight/multi_analysis.py +321 -0
  17. codinsight-0.3.0/src/code_insight/py.typed +0 -0
  18. codinsight-0.3.0/src/code_insight/trend_analysis/__init__.py +0 -0
  19. codinsight-0.3.0/src/code_insight/trend_analysis/trend_analysis.py +176 -0
  20. codinsight-0.3.0/src/codinsight.egg-info/PKG-INFO +108 -0
  21. codinsight-0.3.0/src/codinsight.egg-info/SOURCES.txt +23 -0
  22. codinsight-0.3.0/src/codinsight.egg-info/requires.txt +10 -0
  23. codinsight-0.3.0/src/codinsight.egg-info/top_level.txt +1 -0
  24. codinsight-0.1.0/PKG-INFO +0 -6
  25. codinsight-0.1.0/codinsight.egg-info/PKG-INFO +0 -6
  26. codinsight-0.1.0/codinsight.egg-info/SOURCES.txt +0 -7
  27. codinsight-0.1.0/codinsight.egg-info/top_level.txt +0 -1
  28. codinsight-0.1.0/main.py +0 -6
  29. codinsight-0.1.0/pyproject.toml +0 -7
  30. /codinsight-0.1.0/README.md → /codinsight-0.3.0/src/code_insight/code_analysis/__init__.py +0 -0
  31. {codinsight-0.1.0 → codinsight-0.3.0/src}/codinsight.egg-info/dependency_links.txt +0 -0
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: codinsight
3
+ Version: 0.3.0
4
+ Summary: Add your description here
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: matplotlib>=3.10.5
8
+ Requires-Dist: pandas>=2.3.1
9
+ Requires-Dist: pycodestyle>=2.14.0
10
+ Requires-Dist: pydantic>=2.11.7
11
+ Requires-Dist: pydocstyle>=6.3.0
12
+ Requires-Dist: pytest>=8.4.1
13
+ Requires-Dist: pytest-cov>=6.2.1
14
+ Requires-Dist: radon>=6.0.1
15
+ Requires-Dist: reportlab>=4.4.3
16
+ Requires-Dist: scikit-learn>=1.7.1
17
+
18
+ Codinsight - 複数ファイル解析の利用方法
19
+
20
+ 概要
21
+ - 複数のファイルやディレクトリを再帰的に走査し、既存の解析エンジン(Style/Struct/Readability/Redundancy/Algorithm/Complexity/Quality)で一括解析を実行
22
+ - 拡張子のフィルタや除外パターン(node_modules, .git など)に対応
23
+ - 結果をファイル単位と集約統計(平均など)で取得可能
24
+ - Pydantic BaseModel で JSON 化が容易
25
+
26
+ ## API 使用例
27
+
28
+ ```python
29
+ from code_insight.core import CodeAnalysisType
30
+ from code_insight.multi_analysis import MultiFileAnalyzer
31
+
32
+ analyzer = MultiFileAnalyzer(
33
+ exts={".py"},
34
+ excludes={"node_modules", "target", ".git", ".venv", "__pycache__"},
35
+ )
36
+ result = analyzer.analyze(
37
+ ["src", "tests"],
38
+ [CodeAnalysisType.STYLE, CodeAnalysisType.STRUCT],
39
+ )
40
+ print(result.model_dump_json())
41
+ ```
42
+
43
+ ## 設定のカスタマイズ
44
+
45
+ ```python
46
+ from code_insight.core import CodeAnalysis, AnalysisConfigs, CodeAnalysisType
47
+ from code_insight.code_analysis.quality import QualityAnalysisConfig
48
+ from code_insight.code_analysis.redundancy import RedundancyAnalysisConfig
49
+ from code_insight.code_analysis.style import StyleAnalysisConfig
50
+
51
+ # カスタム設定の作成
52
+ configs = AnalysisConfigs(
53
+ quality=QualityAnalysisConfig(
54
+ long_param_threshold=3, # デフォルト: 5
55
+ enabled=True
56
+ ),
57
+ redundancy=RedundancyAnalysisConfig(
58
+ long_function_lines_threshold=30, # デフォルト: 50
59
+ long_function_complexity_threshold=8, # デフォルト: 10
60
+ ignored_function_names={"main", "__init__", "setup"}
61
+ ),
62
+ style=StyleAnalysisConfig(
63
+ function_name_pattern=r"^[a-z_][a-z0-9_]*$", # snake_case
64
+ class_name_pattern=r"^[A-Z][a-zA-Z0-9]*$" # PascalCase
65
+ )
66
+ )
67
+
68
+ # 設定を使用した解析
69
+ analysis = CodeAnalysis(source_code, configs)
70
+ result = analysis.analyze([CodeAnalysisType.QUALITY, CodeAnalysisType.REDUNDANCY])
71
+
72
+ # 複数ファイル解析での設定使用
73
+ analyzer = MultiFileAnalyzer(configs=configs)
74
+ result = analyzer.analyze(["src"], [CodeAnalysisType.STYLE])
75
+ ```
76
+
77
+ ### 設定可能な項目
78
+
79
+ #### Quality解析
80
+ - `long_param_threshold`: 長引数関数の閾値(デフォルト: 5)
81
+ - `enabled`: 解析の有効/無効(デフォルト: True)
82
+
83
+ #### Redundancy解析
84
+ - `long_function_lines_threshold`: 長大関数の行数閾値(デフォルト: 50)
85
+ - `long_function_complexity_threshold`: 長大関数の複雑度閾値(デフォルト: 10)
86
+ - `ignored_function_names`: 未使用コード検出で無視する関数名(デフォルト: {"main", "__init__", "__main__"})
87
+
88
+ #### Style解析
89
+ - `function_name_pattern`: 関数名の正規表現パターン(デフォルト: snake_case)
90
+ - `class_name_pattern`: クラス名の正規表現パターン(デフォルト: PascalCase)
91
+
92
+ #### その他の解析エンジン
93
+ - Algorithm, Complexity, Readability, Structの各解析エンジンにも同様の設定項目があります
94
+
95
+ 主なオプション
96
+ - exts: 対象拡張子のセット(デフォルト: {".py"})
97
+ - excludes: 除外ディレクトリ名のセット(デフォルト: {"node_modules", "target", ".git", ".venv", "__pycache__"})
98
+
99
+ 返却データの構造
100
+ - files: 各ファイルの解析結果(解析タイプ名 → メトリクス辞書)
101
+ - aggregate:
102
+ - total_files: 解析対象に収集されたファイル数
103
+ - analyzed_files: 実際に解析に成功したファイル数
104
+ - errors: 解析時にエラーとなったファイルパスの一覧
105
+ - by_type_avg: 解析タイプごとの各数値メトリクスの平均値
106
+
107
+ 注意
108
+ - 現時点では直列処理のみ対応。大規模データや並列化は将来的な拡張予定
@@ -0,0 +1,91 @@
1
+ Codinsight - 複数ファイル解析の利用方法
2
+
3
+ 概要
4
+ - 複数のファイルやディレクトリを再帰的に走査し、既存の解析エンジン(Style/Struct/Readability/Redundancy/Algorithm/Complexity/Quality)で一括解析を実行
5
+ - 拡張子のフィルタや除外パターン(node_modules, .git など)に対応
6
+ - 結果をファイル単位と集約統計(平均など)で取得可能
7
+ - Pydantic BaseModel で JSON 化が容易
8
+
9
+ ## API 使用例
10
+
11
+ ```python
12
+ from code_insight.core import CodeAnalysisType
13
+ from code_insight.multi_analysis import MultiFileAnalyzer
14
+
15
+ analyzer = MultiFileAnalyzer(
16
+ exts={".py"},
17
+ excludes={"node_modules", "target", ".git", ".venv", "__pycache__"},
18
+ )
19
+ result = analyzer.analyze(
20
+ ["src", "tests"],
21
+ [CodeAnalysisType.STYLE, CodeAnalysisType.STRUCT],
22
+ )
23
+ print(result.model_dump_json())
24
+ ```
25
+
26
+ ## 設定のカスタマイズ
27
+
28
+ ```python
29
+ from code_insight.core import CodeAnalysis, AnalysisConfigs, CodeAnalysisType
30
+ from code_insight.code_analysis.quality import QualityAnalysisConfig
31
+ from code_insight.code_analysis.redundancy import RedundancyAnalysisConfig
32
+ from code_insight.code_analysis.style import StyleAnalysisConfig
33
+
34
+ # カスタム設定の作成
35
+ configs = AnalysisConfigs(
36
+ quality=QualityAnalysisConfig(
37
+ long_param_threshold=3, # デフォルト: 5
38
+ enabled=True
39
+ ),
40
+ redundancy=RedundancyAnalysisConfig(
41
+ long_function_lines_threshold=30, # デフォルト: 50
42
+ long_function_complexity_threshold=8, # デフォルト: 10
43
+ ignored_function_names={"main", "__init__", "setup"}
44
+ ),
45
+ style=StyleAnalysisConfig(
46
+ function_name_pattern=r"^[a-z_][a-z0-9_]*$", # snake_case
47
+ class_name_pattern=r"^[A-Z][a-zA-Z0-9]*$" # PascalCase
48
+ )
49
+ )
50
+
51
+ # 設定を使用した解析
52
+ analysis = CodeAnalysis(source_code, configs)
53
+ result = analysis.analyze([CodeAnalysisType.QUALITY, CodeAnalysisType.REDUNDANCY])
54
+
55
+ # 複数ファイル解析での設定使用
56
+ analyzer = MultiFileAnalyzer(configs=configs)
57
+ result = analyzer.analyze(["src"], [CodeAnalysisType.STYLE])
58
+ ```
59
+
60
+ ### 設定可能な項目
61
+
62
+ #### Quality解析
63
+ - `long_param_threshold`: 長引数関数の閾値(デフォルト: 5)
64
+ - `enabled`: 解析の有効/無効(デフォルト: True)
65
+
66
+ #### Redundancy解析
67
+ - `long_function_lines_threshold`: 長大関数の行数閾値(デフォルト: 50)
68
+ - `long_function_complexity_threshold`: 長大関数の複雑度閾値(デフォルト: 10)
69
+ - `ignored_function_names`: 未使用コード検出で無視する関数名(デフォルト: {"main", "__init__", "__main__"})
70
+
71
+ #### Style解析
72
+ - `function_name_pattern`: 関数名の正規表現パターン(デフォルト: snake_case)
73
+ - `class_name_pattern`: クラス名の正規表現パターン(デフォルト: PascalCase)
74
+
75
+ #### その他の解析エンジン
76
+ - Algorithm, Complexity, Readability, Structの各解析エンジンにも同様の設定項目があります
77
+
78
+ 主なオプション
79
+ - exts: 対象拡張子のセット(デフォルト: {".py"})
80
+ - excludes: 除外ディレクトリ名のセット(デフォルト: {"node_modules", "target", ".git", ".venv", "__pycache__"})
81
+
82
+ 返却データの構造
83
+ - files: 各ファイルの解析結果(解析タイプ名 → メトリクス辞書)
84
+ - aggregate:
85
+ - total_files: 解析対象に収集されたファイル数
86
+ - analyzed_files: 実際に解析に成功したファイル数
87
+ - errors: 解析時にエラーとなったファイルパスの一覧
88
+ - by_type_avg: 解析タイプごとの各数値メトリクスの平均値
89
+
90
+ 注意
91
+ - 現時点では直列処理のみ対応。大規模データや並列化は将来的な拡張予定
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "codinsight"
7
+ version = "0.3.0"
8
+ description = "Add your description here"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ dependencies = [
12
+ "matplotlib>=3.10.5",
13
+ "pandas>=2.3.1",
14
+ "pycodestyle>=2.14.0",
15
+ "pydantic>=2.11.7",
16
+ "pydocstyle>=6.3.0",
17
+ "pytest>=8.4.1",
18
+ "pytest-cov>=6.2.1",
19
+ "radon>=6.0.1",
20
+ "reportlab>=4.4.3",
21
+ "scikit-learn>=1.7.1",
22
+ ]
23
+
24
+ [tool.mypy]
25
+ plugins = ["pydantic.mypy"]
26
+
27
+ [tool.isort]
28
+ profile = "black"
29
+
30
+ [tool.pydocstyle]
31
+ ignore = ["D100", "D104", "D203", "D205", "D212", "D400", "D415"]
32
+ addopts = "--exclude=tests"
33
+
34
+ [tool.hatch.build.targets.wheel]
35
+ packages = ["src/code_insight"]
36
+ include = ["src/code_insight/py.typed"]
37
+
38
+ [tool.ruff]
39
+ line-length = 88
40
+ include = ["codinsight/**/*.py"]
41
+
42
+ [tool.ruff.lint]
43
+ select = ["F", "E", "I", "B"]
44
+
45
+ [tool.ruff.lint.isort]
46
+ # black profileと同等の設定
47
+ split-on-trailing-comma = true
48
+ combine-as-imports = true
49
+
50
+ [tool.ruff.format]
51
+ quote-style = "double"
52
+ indent-style = "space"
53
+
54
+ [tool.pytest.ini_options]
55
+ testpaths = ["tests"]
56
+ pythonpath = ["src"]
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,57 @@
1
+ from .code_analysis.algorithm import (
2
+ Algorithm,
3
+ AlgorithmAnalysisConfig,
4
+ AlgorithmAnalysisResult,
5
+ )
6
+ from .code_analysis.complexity import (
7
+ Complexity,
8
+ ComplexityAnalysisConfig,
9
+ ComplexityAnalysisResult,
10
+ )
11
+ from .code_analysis.quality import Quality, QualityAnalysisConfig, QualityAnalysisResult
12
+ from .code_analysis.readability import (
13
+ Readability,
14
+ ReadabilityAnalysisConfig,
15
+ ReadabilityAnalysisResult,
16
+ )
17
+ from .code_analysis.redundancy import (
18
+ Redundancy,
19
+ RedundancyAnalysisConfig,
20
+ RedundancyAnalysisResult,
21
+ )
22
+ from .code_analysis.struct import Struct, StructAnalysisConfig, StructAnalysisResult
23
+ from .code_analysis.style import Style, StyleAnalysisConfig, StyleAnalysisResult
24
+ from .core import AnalysisConfigs, CodeAnalysis, CodeAnalysisType
25
+ from .multi_analysis import FileAnalysisResult, MultiAnalysisResult, MultiFileAnalyzer
26
+ from .trend_analysis.trend_analysis import TrendAnalysis
27
+
28
+ __all__ = [
29
+ "CodeAnalysis",
30
+ "CodeAnalysisType",
31
+ "AnalysisConfigs",
32
+ "MultiFileAnalyzer",
33
+ "MultiAnalysisResult",
34
+ "FileAnalysisResult",
35
+ "Readability",
36
+ "ReadabilityAnalysisResult",
37
+ "ReadabilityAnalysisConfig",
38
+ "Algorithm",
39
+ "AlgorithmAnalysisResult",
40
+ "AlgorithmAnalysisConfig",
41
+ "Complexity",
42
+ "ComplexityAnalysisResult",
43
+ "ComplexityAnalysisConfig",
44
+ "Quality",
45
+ "QualityAnalysisResult",
46
+ "QualityAnalysisConfig",
47
+ "Redundancy",
48
+ "RedundancyAnalysisResult",
49
+ "RedundancyAnalysisConfig",
50
+ "Struct",
51
+ "StructAnalysisResult",
52
+ "StructAnalysisConfig",
53
+ "Style",
54
+ "StyleAnalysisResult",
55
+ "StyleAnalysisConfig",
56
+ "TrendAnalysis",
57
+ ]
@@ -0,0 +1,91 @@
1
+ from abc import ABC, abstractmethod
2
+ from typing import Generic, TypeVar
3
+
4
+ from pydantic import BaseModel
5
+
6
+
7
+ class BaseAnalysisConfig(BaseModel):
8
+ """
9
+ 解析設定のベースクラス
10
+
11
+ Attributes
12
+ ----------
13
+ enabled : bool
14
+ 解析の有効/無効フラグ, by default True
15
+ """
16
+
17
+ enabled: bool = True
18
+
19
+
20
+ class BaseAnalysisResult(BaseModel):
21
+ """
22
+ 解析結果のベースモデル
23
+
24
+ Notes
25
+ -----
26
+ 全ての解析結果クラスの基底クラス
27
+ """
28
+
29
+
30
+ R = TypeVar("R", bound=BaseAnalysisResult)
31
+ C = TypeVar("C", bound=BaseAnalysisConfig)
32
+
33
+
34
+ class AbstractAnalysis(ABC, Generic[R, C]):
35
+ """
36
+ 解析抽象クラス
37
+
38
+ Parameters
39
+ ----------
40
+ R : TypeVar
41
+ 解析結果の型
42
+ C : TypeVar
43
+ 解析設定の型
44
+
45
+ Attributes
46
+ ----------
47
+ config : C
48
+ 解析設定
49
+ """
50
+
51
+ config: C
52
+
53
+ def __init__(self, config: C | None = None) -> None:
54
+ """
55
+ コンストラクタ
56
+
57
+ Parameters
58
+ ----------
59
+ config : C | None, optional
60
+ 解析設定, by default None
61
+ """
62
+ self.config = config or self.get_default_config()
63
+
64
+ @abstractmethod
65
+ def get_default_config(self) -> C:
66
+ """
67
+ デフォルト設定を取得
68
+
69
+ Returns
70
+ -------
71
+ C
72
+ デフォルト設定
73
+ """
74
+ raise NotImplementedError("get_default_config method must be implemented")
75
+
76
+ @abstractmethod
77
+ def analyze(self, source_code: str) -> R:
78
+ """
79
+ コードを解析する
80
+
81
+ Parameters
82
+ ----------
83
+ source_code : str
84
+ 解析対象のソースコード
85
+
86
+ Returns
87
+ -------
88
+ R
89
+ 解析結果
90
+ """
91
+ raise NotImplementedError("analyze method must be implemented")