MetaCredo.Check.Utils (MetaCredo v0.1.0)

View Source

Shared utilities for check implementations.

Provides function classification helpers to reduce false positives across security, observability, and other checks that match on function call names.

Summary

Functions

Returns true if a variable name represents a module attribute (starts with @), which should be excluded from snake_case checks since module attribute names follow their own conventions.

Returns true if the string looks like a module name (PascalCase or contains dots like Enum.map), not a regular variable.

Returns true if the function name belongs to a well-known standard library module that should never be flagged as user-facing I/O, HTTP, auth, file operations, etc.

Returns true if a variable name is a well-known Elixir special form or compiler artifact that should be excluded from naming checks.

Functions

module_attribute?(arg1)

@spec module_attribute?(String.t()) :: boolean()

Returns true if a variable name represents a module attribute (starts with @), which should be excluded from snake_case checks since module attribute names follow their own conventions.

module_name?(name)

@spec module_name?(String.t()) :: boolean()

Returns true if the string looks like a module name (PascalCase or contains dots like Enum.map), not a regular variable.

safe_stdlib_call?(func_name)

@spec safe_stdlib_call?(String.t()) :: boolean()

Returns true if the function name belongs to a well-known standard library module that should never be flagged as user-facing I/O, HTTP, auth, file operations, etc.

This prevents false positives like Keyword.get being flagged as an HTTP "get" call, or Map.fetch! being flagged as a database "fetch".

special_variable?(name)

@spec special_variable?(String.t()) :: boolean()

Returns true if a variable name is a well-known Elixir special form or compiler artifact that should be excluded from naming checks.