Skip to content

New erl_files_strict (+hrl +beam) rule: {elvis_style, no_process_dict_usage} #425

@paulo-ferraz-oliveira

Description

@paulo-ferraz-oliveira

Name

no_process_dict_usage

Brief Description

Use of Erlang’s process dictionary should be avoided.

Problematic code

put(Key, Value)

...

get(Key)

Correct code

Here is an alternative that uses the process state, too, but in a more explicit manner.

gen_server:cast(self(), {update_pd, {Key, Value}})

Rationale

Updating the process dictionary isn't, by itself, a bad practice, but it should nonetheless be used with care. This rule will warn you to make a decision on whether your implementation could be reworked or not.

Some problems occurring from using the process dictionary:

  • Hidden State
  • Hard to Test
  • Poor Traceability
  • Breaks Functional Paradigm
  • Concurrency Hazards
  • ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions