Skip to main content

Add your description here

Project description

Codinsight - 複数ファイル解析の利用方法

概要

  • 複数のファイルやディレクトリを再帰的に走査し、既存の解析エンジン(Style/Struct/Readability/Redundancy/Algorithm/Complexity/Quality)で一括解析を実行
  • 拡張子のフィルタや除外パターン(node_modules, .git など)に対応
  • 結果をファイル単位と集約統計(平均など)で取得可能
  • Pydantic BaseModel で JSON 化が容易

API 使用例

from code_insight.core import CodeAnalysisType
from code_insight.multi_analysis import MultiFileAnalyzer

analyzer = MultiFileAnalyzer(
    exts={".py"},
    excludes={"node_modules", "target", ".git", ".venv", "__pycache__"},
)
result = analyzer.analyze(
    ["src", "tests"],
    [CodeAnalysisType.STYLE, CodeAnalysisType.STRUCT],
)
print(result.model_dump_json())

設定のカスタマイズ

from code_insight.core import CodeAnalysis, AnalysisConfigs, CodeAnalysisType
from code_insight.code_analysis.quality import QualityAnalysisConfig
from code_insight.code_analysis.redundancy import RedundancyAnalysisConfig
from code_insight.code_analysis.style import StyleAnalysisConfig

# カスタム設定の作成
configs = AnalysisConfigs(
    quality=QualityAnalysisConfig(
        long_param_threshold=3,  # デフォルト: 5
        enabled=True
    ),
    redundancy=RedundancyAnalysisConfig(
        long_function_lines_threshold=30,  # デフォルト: 50
        long_function_complexity_threshold=8,  # デフォルト: 10
        ignored_function_names={"main", "__init__", "setup"}
    ),
    style=StyleAnalysisConfig(
        function_name_pattern=r"^[a-z_][a-z0-9_]*$",  # snake_case
        class_name_pattern=r"^[A-Z][a-zA-Z0-9]*$"     # PascalCase
    )
)

# 設定を使用した解析
analysis = CodeAnalysis(source_code, configs)
result = analysis.analyze([CodeAnalysisType.QUALITY, CodeAnalysisType.REDUNDANCY])

# 複数ファイル解析での設定使用
analyzer = MultiFileAnalyzer(configs=configs)
result = analyzer.analyze(["src"], [CodeAnalysisType.STYLE])

設定可能な項目

Quality解析

  • long_param_threshold: 長引数関数の閾値(デフォルト: 5)
  • enabled: 解析の有効/無効(デフォルト: True)

Redundancy解析

  • long_function_lines_threshold: 長大関数の行数閾値(デフォルト: 50)
  • long_function_complexity_threshold: 長大関数の複雑度閾値(デフォルト: 10)
  • ignored_function_names: 未使用コード検出で無視する関数名(デフォルト: {"main", "init", "main"})

Style解析

  • function_name_pattern: 関数名の正規表現パターン(デフォルト: snake_case)
  • class_name_pattern: クラス名の正規表現パターン(デフォルト: PascalCase)

その他の解析エンジン

  • Algorithm, Complexity, Readability, Structの各解析エンジンにも同様の設定項目があります

主なオプション

  • exts: 対象拡張子のセット(デフォルト: {".py"})
  • excludes: 除外ディレクトリ名のセット(デフォルト: {"node_modules", "target", ".git", ".venv", "pycache"})

返却データの構造

  • files: 各ファイルの解析結果(解析タイプ名 → メトリクス辞書)
  • aggregate:
    • total_files: 解析対象に収集されたファイル数
    • analyzed_files: 実際に解析に成功したファイル数
    • errors: 解析時にエラーとなったファイルパスの一覧
    • by_type_avg: 解析タイプごとの各数値メトリクスの平均値

注意

  • 現時点では直列処理のみ対応。大規模データや並列化は将来的な拡張予定

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codinsight-0.0.8.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codinsight-0.0.8-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file codinsight-0.0.8.tar.gz.

File metadata

  • Download URL: codinsight-0.0.8.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for codinsight-0.0.8.tar.gz
Algorithm Hash digest
SHA256 147c37392a2ac867fdb21b25fa017e5f3947519ba684ec8aa6a8e67476e32c34
MD5 d77f3b28edb8a2e78b1e0cf5e5fab7d9
BLAKE2b-256 5727dc43fb4f308be8b929ab6c96681919a1dc773a46ac7e70918201db6dd332

See more details on using hashes here.

File details

Details for the file codinsight-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: codinsight-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for codinsight-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4f517ad30c9ad5f49536122874b07cff4c7b2cbe6e2f7652715a0c7f01dcaf55
MD5 7eca72f1a36290bca3a71718563b16df
BLAKE2b-256 580a30c70fcab244c2f5ad1a11cf3f7c7fb86b49e0b3852c47614aeac66d863d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page