Skip to content

Commit

Permalink
Merge pull request #625 from Workiva/clean-up-static-analysis
Browse files Browse the repository at this point in the history
Address static analysis lints/hints
  • Loading branch information
rmconsole3-wf authored Sep 10, 2020
2 parents 3e9bb81 + 32f97b4 commit 94422f9
Show file tree
Hide file tree
Showing 102 changed files with 161 additions and 213 deletions.
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ analyzer:
- app/**
- tools/analyzer_plugin/**
errors:
unused_import: warning
duplicate_import: warning
missing_required_param: error
must_call_super: error
linter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';
// ignore: implementation_imports
import 'package:over_react/src/component/test_fixtures/redraw_counter_component_mixin.dart';

import 'package:todo_client/src/actions.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';
// ignore: implementation_imports
import 'package:over_react/src/component/test_fixtures/redraw_counter_component_mixin.dart';

import 'package:todo_client/src/store.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:html';

import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';
// ignore: implementation_imports
import 'package:over_react/src/component/test_fixtures/redraw_counter_component_mixin.dart';

import 'package:todo_client/src/actions.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';
// ignore: implementation_imports
import 'package:over_react/src/component/test_fixtures/redraw_counter_component_mixin.dart';

import 'package:todo_client/src/store.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:html';

import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';
// ignore: implementation_imports
import 'package:over_react/src/component/test_fixtures/redraw_counter_component_mixin.dart';

import 'package:todo_client/src/actions.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ library todo_client.src.components.user_selector;

import 'package:over_react/over_react.dart';
import 'package:over_react/over_react_redux.dart';
// ignore: implementation_imports
import 'package:over_react/src/component/test_fixtures/redraw_counter_component_mixin.dart';

import 'package:todo_client/src/store.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ bool muiJsIsAvailable() {
}

void initializeComponentTests() {
setClientConfiguration();
enableTestMode();
if (!muiJsIsAvailable()) return;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import 'package:todo_client/src/utils.dart';
external JsMap get mockJsMap;

main() {
setClientConfiguration();
JsBackedMap mockJsBackedMap;

setUpAll(() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import 'package:todo_client/src/components/shared/material_ui.dart';
import 'fixtures/utils.dart';

main() {
setClientConfiguration();
if (!muiJsIsAvailable()) return;

group('MaterialUI', () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@TestOn('browser')
import 'dart:convert';

import 'package:over_react/over_react.dart';
import 'package:test/test.dart';

import 'package:todo_client/src/actions.dart';
Expand All @@ -13,7 +12,6 @@ import 'package:todo_client/src/store.dart';
import '../fixtures/utils.dart';

main() {
setClientConfiguration();
const reasonCurrentSetShouldBePersisted =
'The state update should be persisted as the "current" set in window.localStorage';

Expand Down
3 changes: 0 additions & 3 deletions app/over_react_redux/todo_client/web/main.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import 'dart:html';

import 'package:over_react/over_react.dart';
import 'package:over_react/react_dom.dart' as react_dom;
import 'package:over_react/over_react_redux.dart';

import 'package:todo_client/todo_client.dart';

main() {
setClientConfiguration();

final container = querySelector('#todo-container');

final app = (ReduxProvider()..store = getStore())(
Expand Down
2 changes: 0 additions & 2 deletions example/builder/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import './src/generic_inheritance_super.dart';
import './src/function_component.dart' as function;

main() {
setClientConfiguration();

react_dom.render(
Dom.div()(
Dom.h3()('Components'),
Expand Down
2 changes: 0 additions & 2 deletions example/builder/src/basic_with_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// limitations under the License.

import 'package:over_react/over_react.dart';
import 'props_mixin.dart' as pm;
import 'state_mixin.dart';

part 'basic_with_state.over_react.g.dart';

Expand Down
2 changes: 1 addition & 1 deletion example/builder/src/private_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:over_react/over_react.dart';

part 'private_component.over_react.g.dart';

UiFactory<_PrivateProps> _Private = _$_Private; // ignore: undefined_identifier
UiFactory<_PrivateProps> _Private = _$_Private; // ignore: undefined_identifier, unused_element

mixin _PrivateProps on UiProps {
bool prop1;
Expand Down
1 change: 1 addition & 0 deletions example/builder/src/with_legacy_props_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mixin BasicPropsMixin on UiProps {
String basicProp;
}

// ignore: deprecated_member_use_from_same_package
class BasicProps = UiProps with BasicPropsMixin, TransitionPropsMixin;

class BasicComponent extends UiComponent2<BasicProps> {
Expand Down
3 changes: 0 additions & 3 deletions example/context/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ import 'dart:html';

import 'package:over_react/over_react.dart';
import 'package:over_react/components.dart' as v2;
import 'package:react/react_client.dart';
import 'package:react/react_dom.dart' as react_dom;
import './components/my_provider_component.dart';
import './components/my_context_component.dart';
import './context.dart';

main() {
setClientConfiguration();

react_dom.render(
v2.ErrorBoundary()(
MyProvider()(
Expand Down
1 change: 1 addition & 0 deletions lib/over_react.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export 'package:react/react.dart'
export 'package:react/react_client/js_backed_map.dart' show JsBackedMap;

export 'package:react/react_client.dart'
// ignore: deprecated_member_use
show setClientConfiguration, ReactElement, ReactComponentFactoryProxy;
export 'package:react/react_client/react_interop.dart' show ReactErrorInfo, Ref;
export 'package:react/hooks.dart' show StateHook, ReducerHook;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/builder/codegen/names.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FactoryNames {
///
/// - Input: `Foo`
/// - Output: `_$Foo`
String get implName => '$_prefix$privateSourcePrefix${unprefixedConsumerName}';
String get implName => '$_prefix$privateSourcePrefix$unprefixedConsumerName';

/// The name of the generated function component props config for the factory.
///
Expand Down
1 change: 0 additions & 1 deletion lib/src/builder/parsing/declarations_from_members.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Iterable<BoilerplateDeclaration> getBoilerplateDeclarations(
if (members.isEmpty) return;

final _consumedMembers = <BoilerplateMember>{};
final _functionComponentFactories = <BoilerplateFactory>{};

/// Indicate that [member] has been grouped into a declaration,
/// so that it is not grouped into another declaration.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/builder/parsing/members/props_and_state_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ annotations.TypedMap getPropsOrStateAnnotation(bool isProps, AnnotatedNode node)
final meta = isProps
? (InstantiatedMeta<annotations.Props>(node) ??
InstantiatedMeta<annotations.AbstractProps>(node) ??
// ignore: deprecated_member_use_from_same_package
InstantiatedMeta<annotations.PropsMixin>(node))
: (InstantiatedMeta<annotations.State>(node) ??
InstantiatedMeta<annotations.AbstractState>(node) ??
// ignore: deprecated_member_use_from_same_package
InstantiatedMeta<annotations.StateMixin>(node));

return meta?.value ?? (isProps ? annotations.Props() : annotations.State());
Expand Down
6 changes: 3 additions & 3 deletions lib/src/component/_deprecated/abstract_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ abstract class AbstractTransitionComponent<T extends AbstractTransitionProps,

/// Begin showing the [AbstractTransitionComponent], unless:
/// * The [AbstractTransitionComponent] is already shown or is in the process of showing.
/// * The [AbstractTransitionProps.onWillShow] callback returns `false`.
/// * The [TransitionPropsMixin.onWillShow] callback returns `false`.
void _handleShow() {
if (isOrWillBeShown) {
return;
Expand All @@ -179,7 +179,7 @@ abstract class AbstractTransitionComponent<T extends AbstractTransitionProps,

/// Begin hiding the [AbstractTransitionComponent], unless:
/// * The [AbstractTransitionComponent] is already hidden or is in the process of being hidden.
/// * The [AbstractTransitionProps.onWillHide] callback returns `false`.
/// * The [TransitionPropsMixin.onWillHide] callback returns `false`.
void _handleHide() {
if (isOrWillBeHidden) {
return;
Expand Down Expand Up @@ -426,7 +426,7 @@ abstract class AbstractTransitionComponent<T extends AbstractTransitionProps,
_handleHide();
}

/// Toggles the visibility of the [AbstractTransitionComponent] based on the value of [AbstractTransitionState.transitionPhase].
/// Toggles the visibility of the [AbstractTransitionComponent] based on the value of `AbstractTransitionState.transitionPhase`.
void toggle() {
if (isOrWillBeShown) {
/// If the [AbstractTransitionComponent] is shown or in the process of showing, hide it.
Expand Down
1 change: 1 addition & 0 deletions lib/src/component/_deprecated/error_boundary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class ErrorBoundaryComponent<T extends ErrorBoundaryProps, S extends ErrorBounda
///
/// This can be called manually on the component instance using a `ref` -
/// or by passing in a new child instance after a child has thrown an error.
@override
void reset() {
setState(initialState);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/src/component/_deprecated/error_boundary_mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// ignore_for_file: deprecated_member_use_from_same_package
import 'dart:async';

import 'package:logging/logging.dart';
Expand Down Expand Up @@ -369,8 +370,8 @@ mixin ErrorBoundaryMixin<T extends ErrorBoundaryPropsMixin, S extends ErrorBound
)();
}

/// Called via [componentDidCatch] to start a `Timer` that will nullify the [_lastError] and [_lastErrorInfo]
/// internal fields that keep track of the last error thrown.
/// Called via [componentDidCatch] to start a `Timer` that will nullify the [_domAtTimeOfError]
/// internal field that keeps track of the last error thrown.
///
/// If an identical error is thrown by an identical child component twice in a row:
///
Expand Down
1 change: 1 addition & 0 deletions lib/src/component/aria_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ abstract class $AriaPropsMixin {

/// Typed getters/setters for accessibility props.
/// To be used as a mixin for React components and builders.
// ignore: deprecated_member_use_from_same_package
@PropsMixin(keyNamespace: '')
abstract class _$AriaPropsMixin {
Map get props;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/component/dummy_component2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import 'package:over_react/over_react.dart';
part 'dummy_component2.over_react.g.dart';

@Factory()
// ignore: undefined_identifier
// ignore: undefined_identifier, unused_element
UiFactory<_Dummy2Props> _Dummy2 = _$_Dummy2;

@Props()
Expand Down
6 changes: 3 additions & 3 deletions lib/src/component/error_boundary_recoverable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ class RecoverableErrorBoundaryComponent<T extends RecoverableErrorBoundaryProps,
)();
}

/// Called via [componentDidCatch] to start a `Timer` that will nullify the [_lastError] and [_lastErrorInfo]
/// internal fields that keep track of the last error thrown.
/// Called via [componentDidCatch] to start a `Timer` that will nullify the [_domAtTimeOfError]
/// internal field that keeps track of the last error thrown.
///
/// If an identical error is thrown by an identical child component twice in a row:
///
Expand All @@ -210,7 +210,7 @@ class RecoverableErrorBoundaryComponent<T extends RecoverableErrorBoundaryProps,
/// * __After the timer's callback fires__ - internal component logic will NOT treat the second error
/// as an unrecoverable one.
///
/// > Not used when [ErrorBoundaryPropsMixin.fallbackUIRenderer] is set.
/// > Not used when `ErrorBoundaryProps.fallbackUIRenderer` is set.
void _startIdenticalErrorTimer() {
if (_identicalErrorTimer != null) return;

Expand Down
2 changes: 0 additions & 2 deletions lib/src/component/fragment_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'package:over_react/src/component_declaration/component_base.dart'
as component_base;
import 'package:over_react/src/component_declaration/builder_helpers.dart'
as builder_helpers;
import 'package:react/react_client.dart';
Expand Down
6 changes: 3 additions & 3 deletions lib/src/component/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Ref<T> useRef<T>([T initialValue]) => react_hooks.useRef(initialValue);

/// Returns a memoized version of the return value of [createFunction].
///
/// If one of the [dependencies] has changed, [createFunction] is run during rendering of the [DartFunctionComponent].
/// If one of the [dependencies] has changed, [createFunction] is run during rendering of the dart function component.
/// This optimization helps to avoid expensive calculations on every render.
///
/// > __Note:__ there are two [rules for using Hooks](https://reactjs.org/docs/hooks-rules.html):
Expand Down Expand Up @@ -362,7 +362,7 @@ Ref<T> useRef<T>([T initialValue]) => react_hooks.useRef(initialValue);
T useMemo<T>(T Function() createFunction, [List<dynamic> dependencies]) =>
react_hooks.useMemo(createFunction, dependencies);

/// Runs [sideEffect] synchronously after a [DartFunctionComponent] renders, but before the screen is updated.
/// Runs [sideEffect] synchronously after a dart function component renders, but before the screen is updated.
///
/// Compare to [useEffect] which runs [sideEffect] after the screen updates.
/// Prefer the standard [useEffect] when possible to avoid blocking visual updates.
Expand Down Expand Up @@ -403,7 +403,7 @@ T useMemo<T>(T Function() createFunction, [List<dynamic> dependencies]) =>
/// Learn more: <https://reactjs.org/docs/hooks-reference.html#uselayouteffect>.
void useLayoutEffect(dynamic Function() sideEffect, [List<Object> dependencies]) => react_hooks.useLayoutEffect(sideEffect, dependencies);

/// Customizes the [ref] value that is exposed to parent components when using [uiForwardRef] by setting [ref.current]
/// Customizes the [ref] value that is exposed to parent components when using [uiForwardRef] by setting [Ref.current]
/// to the return value of [createHandle].
///
/// In most cases, imperative code using refs should be avoided.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/component/prop_mixins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// ignore_for_file: deprecated_member_use_from_same_package

/// Various prop related mixins to be used with `UiComponent` descendants.
library over_react.prop_mixins;

Expand Down
2 changes: 1 addition & 1 deletion lib/src/component/pure_component_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import 'package:over_react/over_react.dart';

/// A mixin to make a [react.Component2] instance behave
/// A mixin to make a `Component2` instance behave
/// like a [ReactJS `PureComponent`](https://reactjs.org/docs/react-api.html#reactpurecomponent).
///
/// The value of `props.children` is not compared deeply by default. Any time a new `ReactElement`
Expand Down
Loading

0 comments on commit 94422f9

Please sign in to comment.