패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.0

dart_code_metrics_annotations

DCM용 주석.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.6만
좋아요
4
Pub 점수
140

패키지 설치

flutter pub add dart_code_metrics_annotations

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Dart Code Metrics (DCM)와 함께 작동하도록 설계된 주석 세트로, 코드 분석을 위한 메타데이터를 제공합니다. 이러한 주석은 특정 규칙을 무시하거나 사용자 정의 메트릭을 지정하는 등 개발자가 Dart 코드의 특정 부분을 강화된 검사 대상으로 표시하는 데 도움을 줍니다. 이 패키지는 여러 플랫폼에서 Flutter 및 Dart 프로젝트에 원활하게 통합되어 정적 분석에 대한 더 정밀한 제어를 가능하게 합니다. 구성 가능한 지시문을 통해 린팅과 코드 품질 강제 실행을 지원합니다.

사용 사례

  • lint 규칙 동작 사용자 정의
  • 코드 품질 검사 개선
  • CI/CD 파이프라인과의 통합
  • 특별 분석을 위해 코드 섹션 표시
  • 팀 전체의 코딩 기준 지원
  • 구조화된 주석을 통한 유지보수성 향상

주요 기능

  • DCM 전용 주석 제공
  • 분석에 대한 세밀한 제어를 가능하게 함
  • 기존 linter 구성과 호환됩니다
  • 다중 플랫폼 프로젝트를 지원합니다
  • 자동 코드 리뷰를 촉진합니다
  • 메트릭 기반 코드 거버넌스를 단순화

적합한 대상

  • Dart 및 Flutter 팀이 DCM 사용
  • 엄격한 코드 품질 기준을 요구하는 프로젝트
  • 자동 린팅이 포함된 CI/CD 환경
  • 사용자 정의 가능한 분석 규칙을 찾는 개발자
  • 일관된 코딩 관행을 시행하는 팀
  • 장기적인 유지보수를 목표로 하는 프로젝트

고려 사항

  • Dart Code Metrics가 설치되어 있어야 합니다
  • 주석은 DCM과 함께 사용될 때만 효과가 있습니다
  • .analysis_options에서 구성 업데이트가 필요할 수 있습니다
  • 독립적이지 않음—더 큰 도구 체인에 의존함
  • 분석 워크플로우에 통합되지 않으면 활용도가 제한적입니다
  • 다른 코드 품질 도구와 함께 사용하는 것이 가장 좋습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Pub Version License package publisher

DCM Annotations

DCM is an advanced linter for Dart and Flutter that helps you analyze and improve your code quality. You can find all available lint rules here.

@Throws()

Used to annotate getters, methods, functions, parameters or local variables that can throw an exception (or multiple exceptions/errors) and therefore an invocation of such declarations must explicitly handle that exception.

For example:

@Throws()
void fn() { /* ... */ }

@Throws({IndexError})
void anotherFn() { /* ... */ }

void main() {
  try {
    fn(); // OK.
  } catch(_) {}

  fn(); // LINT.

  try {
    anotherFn(); // OK.
  } catch(_) {}

  try {
    anotherFn(); // LINT.
  } on Exception catch(_) {}
}

DCM will provide feedback if:

  • an invocation of a declaration with this annotation has unhandled exceptions
  • a declaration is not marked with this annotation, but can throw an exception
  • a declaration is marked with this annotation, but does not have any invocation that throws an exception

For more information, see the documentation for handle-throwing-invocations and prefer-correct-throws.

@AcceptedTypes()

Used to annotate fields or parameters that have a type Object, but should only receive a known subset of types (e.g. String and int).

For example:

void fn() {
  fn(1); // LINT
  SomeClass(false); // LINT
}

void fn(@AcceptedTypes({String, bool}) Object value) {}

class SomeClass {
  @AcceptedTypes({String, int})
  final Object field;

  const SomeClass(this.field);
}

DCM will provide feedback if an invocation receives an argument that does not match the type listed in the @AcceptedTypes().

For more information, see the documentation for pass-correct-accepted-types.

@mutated

Used to annotate parameters or variables that are changed/updated within the function/method body.

For example, the avoid-collection-mutating-methods and avoid-mutating-parameters rules will not trigger on annotated parameters and avoid-not-assignable-collection-types will include such parameters into its analysis.

DCM will provide feedback if the @mutated annotation is missing or unnecessary.

For more information, see the documentation for prefer-correct-mutated and other rules mentioned above.

How to use annotations

Take these steps to use annotations:

  1. Install this package as a regular dependency:

    dart pub add dart_code_metrics_annotations
    

    or:

    flutter pub add dart_code_metrics_annotations
    
  2. Enable rules that rely on DCM annotations and add those annotations to your code.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트