Workiva / Workiva/over_react

over_react analyzer not reporting at compile time required props that are missing, and at runtime, reporting error on required props that are specified

Open
#942 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
432
Forks
57
PR merge metrics
No merged PRs in 30d

Description

  • Issue Type: BUG
  • over_react Version(s): 5.3.0
  • dart version 2.19.6

I got the analyzer plugin set up, and it is indeed showing some warnings in WebStorm, so it's running:

image

However, the main bug I had with pre-null-safe overreact was forgetting to include a required prop and having it default to null. I had really hoped to be warned about this (in fact it seems like the severity should default to error), but in the following code, I have commented out the line // ..mouseover_datas = state.ui_state.mouseover_datas to see if the analyzer plugin will warn me that the required prop mouseover_datas is not being specified, but that does not show up:

UiFactory<DesignFooterProps> ConnectedDesignFooter = connect<AppState, DesignFooterProps>(
  mapStateToProps: (state) {
    BuiltList<MouseoverData> mouseover_datas = state.ui_state.mouseover_datas;
    MouseoverData? first_mouseover_data =
        mouseover_datas.isNotEmpty ? state.ui_state.mouseover_datas.first : null;
    Strand? strand_first_mouseover_data =
        mouseover_datas.isNotEmpty ? state.design.substrand_to_strand[first_mouseover_data!.domain] : null;
    String loaded_filename = state.ui_state.loaded_filename;
    return (DesignFooter()
      // ..mouseover_datas = state.ui_state.mouseover_datas // This should be an error since `mouseover_datas` is declared as `late` below
      ..strand_first_mouseover_data = strand_first_mouseover_data
      ..loaded_filename = loaded_filename);
  },
)(DesignFooter);

UiFactory<DesignFooterProps> DesignFooter = _$DesignFooter;

mixin DesignFooterProps on UiProps {
  late BuiltList<MouseoverData> mouseover_datas;
  Strand? strand_first_mouseover_data;
  late String loaded_filename;
}

class DesignFooterComponent extends UiComponent2<DesignFooterProps> {
  @override
  render() {
    BuiltList<MouseoverData> mouseover_datas = props.mouseover_datas;
    ...

I did try restarting the analyzer server by clicking the red curved arrows in the upper left, but still nothing about this error.

Is there something I need to configure in the overreact analyzer to ask it to warn me about missing required props?

I noticed that this page mentions some customization:

"To configure the plugin, add a over_react key to analysis_options.yaml:"

analyzer:
  plugins:
    - over_react

over_react:
  errors:
    over_react_boilerplate_error: error
    over_react_incorrect_doc_comment_location: warning
    over_react_unnecessary_key: info
    over_react_pseudo_static_lifecycle: ignore

But I can't find any documentation of what all the options are for the analyzer, and what "over_react_missing_required_prop" would actually be.

FYI: @greglittlefield-wf @aaronlademann-wf @kealjones-wk @evanweible-wf @maxwellpeterson-wf

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in tools/analyzer_plugin and reproduce the provided DesignFooter example with Dart 2.19.6 and the over_react plugin configuration in analysis_options.yaml. Trace the required-prop analyzer behavior and its runtime counterpart; done means missing late required props produce the expected compile-time diagnostic while specified required props do not produce a runtime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
frontend, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.