Skip to content

style: use getOrDefault in MajorityElement#5454

Merged
alxkm merged 1 commit intoTheAlgorithms:masterfrom
vil02:use_getOrDefault_in_MajorityElement
Sep 18, 2024
Merged

style: use getOrDefault in MajorityElement#5454
alxkm merged 1 commit intoTheAlgorithms:masterfrom
vil02:use_getOrDefault_in_MajorityElement

Conversation

@vil02
Copy link
Copy Markdown
Member

@vil02 vil02 commented Sep 18, 2024

This PR simplifies the logic inside the majority method.

The background story is that I was experimenting with infer and it was reporting a potential Null dereference (there are about 29 left). In this case it will not happen, but the code can be written better (as in this PR). I am considering including infer into our CI. I will keep you updated.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 18, 2024

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.03%. Comparing base (2f9f448) to head (33e6d27).
⚠️ Report is 852 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5454      +/-   ##
============================================
- Coverage     52.03%   52.03%   -0.01%     
+ Complexity     3238     3237       -1     
============================================
  Files           524      524              
  Lines         15181    15179       -2     
  Branches       2888     2887       -1     
============================================
- Hits           7900     7898       -2     
  Misses         6956     6956              
  Partials        325      325              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vil02 vil02 marked this pull request as ready for review September 18, 2024 17:13
@alxkm alxkm merged commit 7bde152 into TheAlgorithms:master Sep 18, 2024
@vil02 vil02 deleted the use_getOrDefault_in_MajorityElement branch September 19, 2024 08:27
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