Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply suggestions from rust-clippy #6256

Merged
merged 4 commits into from
Aug 29, 2021
Merged

Apply suggestions from rust-clippy #6256

merged 4 commits into from
Aug 29, 2021

Conversation

mischnic
Copy link
Member

@mischnic mischnic commented May 10, 2021

Fix some warnings produced by running https://github.com/rust-lang/rust-clippy

Make Github hide whitespace changes when viewing the diff

  • unnecessary .clone()s
  • use if let Foo(y) = x ... instead of match x { Foo(y) => ..., _ => {} }
  • merge nested if statements into a single one with the conditionA && conditionB
  • remove unnecessary return keywords
  • merge nested type checking if possible:
      if let Lit(lit) = &*arg.expr {
        if let ast::Lit::Str(str_) = lit {

can be

      if let Lit(ast::Lit::Str(str_)) = &*arg.expr {

(same for match)

  • use .map(|v| something(v)) instead of if let Some(v) = ... { something(v)} else {None}
  • use .is_empty() when possible
  • .iter().flatten() instead of for n in list { if Some(n) = n { ...
  • "Object spreading":
    let mut esconfig = EsConfig::default();
    esconfig.jsx = config.is_jsx;
    esconfig.dynamic_import = true;
    esconfig.export_default_from = true;
    esconfig.export_namespace_from = true;
    esconfig.import_meta = true;
    Syntax::Es(esconfig)

becomes:

    Syntax::Es(EsConfig {
      jsx: config.is_jsx,
      dynamic_import: true,
      export_default_from: true,
      export_namespace_from: true,
      import_meta: true,
      ..Default::default()
    })
  • .or_insert(something()) should rather be .or_insert_with(|| something()) so that the function is only called when needed

@height
Copy link

height bot commented May 10, 2021

Link Height tasks by mentioning a task ID in the pull request title or description, commit messages, or comments.

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@parcel-benchmark
Copy link

parcel-benchmark commented May 10, 2021

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 2.18s +35.00ms
Cached 322.00ms -17.00ms 🚀

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 657.00ms +571.00ms ⚠️
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 658.00ms +571.00ms ⚠️
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 658.00ms +571.00ms ⚠️

Cached Bundles

No bundle changes detected.

React HackerNews ✅

Timings

Description Time Difference
Cold 11.07s -61.00ms
Cached 514.00ms +35.00ms ⚠️

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.25m -219.00ms
Cached 1.84s +26.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.4408191d.js 1.77mb +6.00b ⚠️ 21.74s -38.00ms
dist/index.92823b4c.js 694.60kb -11.00b 🚀 57.93s +106.00ms
dist/Modal.62f95654.js 45.30kb +15.00b ⚠️ 57.28s -6.00ms

Cached Bundles

Bundle Size Difference Time Difference
dist/index.8abd161c.js 694.59kb -19.00b 🚀 58.28s +241.00ms
dist/Modal.342d8783.js 45.30kb +15.00b ⚠️ 57.67s +115.00ms

Three.js ✅

Timings

Description Time Difference
Cold 7.97s -5.00ms
Cached 415.00ms -26.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@mischnic mischnic marked this pull request as draft May 14, 2021 08:50
@mischnic mischnic marked this pull request as ready for review May 25, 2021 09:25
@mischnic mischnic force-pushed the js-transformer-clippy branch 2 times, most recently from a72bc3b to 54188fe Compare June 5, 2021 09:37
None => None,
};
let handler = node.handler.map(|handler| handler.fold_with(self));
let finalizer = node.finalizer.map(|finalizer| finalizer.fold_with(self));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL 😲

@devongovett devongovett merged commit 461de11 into v2 Aug 29, 2021
@devongovett devongovett deleted the js-transformer-clippy branch August 29, 2021 18:53
lettertwo added a commit that referenced this pull request Sep 10, 2021
* v2: (69 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 10, 2021
* v2: (38 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 11, 2021
* bdo/number-edgetypes: (70 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* v2: (38 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* bdo/number-edgetypes: (70 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* v2: (42 commits)
  Remove dead link to docs in diagnostic (#6913)
  Fix engines.parcel in SVG packager (#6911)
  Use imported Readable flow type instead of global (#6910)
  Use non-deprecated SVGO options in HTMLNanoOptimizer (#6785)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* v2: (42 commits)
  Remove dead link to docs in diagnostic (#6913)
  Fix engines.parcel in SVG packager (#6911)
  Use imported Readable flow type instead of global (#6910)
  Use non-deprecated SVGO options in HTMLNanoOptimizer (#6785)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* bdo/number-edgetypes: (74 commits)
  Remove dead link to docs in diagnostic (#6913)
  Fix engines.parcel in SVG packager (#6911)
  Use imported Readable flow type instead of global (#6910)
  Use non-deprecated SVGO options in HTMLNanoOptimizer (#6785)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants