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.9.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.9-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codinsight-0.0.9.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.9.tar.gz
Algorithm Hash digest
SHA256 09a7f597256e1a40586f02bf098ef8ccf6e019fde402f8676ec5174ce887d633
MD5 e77af0a5b1904aaa2c97748cfd7c269d
BLAKE2b-256 76d74daac0cb3f62b98089019ac2c4cc67c71c25bf8397ddfd5168650a98d81d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codinsight-0.0.9-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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e464fffa93b10b711abaf2bf9ac4967226cac6ac36b18883d82a1def7f2aa941
MD5 d883ec396fff9a1fedc8f4621573baaa
BLAKE2b-256 7e07f3b8a7a0e886d0ccb80241b9d3c1927a962337a70626876856820a94f8c2

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