Skip to content

Commit 04fa3d9

Browse files
mmkalQu4trocrutchcorn
authored
fix: remove fallthrough switch statement (#1247)
* chore: fix broken link in README.md (#1154) * fix(react-native): fix for "<Intermediate Value>.stream is not a function" errors in React Native (#1156) * chore: remove fallthrough switch statement * docs: add @mmkal as a contributor * docs: add @mmkal as a contributor Co-authored-by: Xavier Francisco <[email protected]> Co-authored-by: Corbin Crutchley <[email protected]>
1 parent fca0a80 commit 04fa3d9

File tree

3 files changed

+34
-29
lines changed

3 files changed

+34
-29
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,15 @@
463463
"code"
464464
]
465465
},
466+
{
467+
"login": "mmkal",
468+
"name": "Misha Kaletsky",
469+
"avatar_url": "https://avatars2.githubusercontent.com/u/15040698?v=4",
470+
"profile": "https://github.com/mmkal",
471+
"contributions": [
472+
"code"
473+
]
474+
},
466475
{
467476
"login": "rczulch",
468477
"name": "Richard C. Zulch",

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
328328
<td align="center"><a href="https://github.com/willstott101"><img src="https://avatars2.githubusercontent.com/u/335152?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Will Stott</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=willstott101" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=willstott101" title="Tests">⚠️</a></td>
329329
<td align="center"><a href="http://mtnspring.org/"><img src="https://avatars2.githubusercontent.com/u/223277?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Seth Nickell</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Asnickell" title="Bug reports">🐛</a></td>
330330
<td align="center"><a href="https://www.alextitarenko.me/"><img src="https://avatars0.githubusercontent.com/u/3290313?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Alex Titarenko</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=alex-titarenko" title="Code">💻</a></td>
331+
<td align="center"><a href="https://github.com/mmkal"><img src="https://avatars2.githubusercontent.com/u/15040698?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Misha Kaletsky</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=mmkal" title="Code">💻</a></td>
331332
<td align="center"><a href="https://github.com/rczulch"><img src="https://avatars1.githubusercontent.com/u/54646976?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Richard C. Zulch</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=rczulch" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=rczulch" title="Documentation">📖</a></td>
332333
<td align="center"><a href="https://scrapbox.io/mkizka/README"><img src="https://avatars.githubusercontent.com/u/30231179?v=4?s=60" width="60px;" alt=""/><br /><sub><b>mkizka</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=mkizka" title="Code">💻</a></td>
333334
<td align="center"><a href="https://ryotak.me/"><img src="https://avatars.githubusercontent.com/u/49341894?v=4?s=60" width="60px;" alt=""/><br /><sub><b>RyotaK</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3ARy0taK" title="Bug reports">🐛</a></td>

src/storage/readObject.js

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,36 +55,31 @@ export async function _readObject({
5555
return result
5656
}
5757

58-
// BEHOLD! THE ONLY TIME I'VE EVER WANTED TO USE A CASE STATEMENT WITH FOLLOWTHROUGH!
59-
// eslint-ignore
60-
/* eslint-disable no-fallthrough */
61-
switch (result.format) {
62-
case 'deflated': {
63-
result.object = Buffer.from(await inflate(result.object))
64-
result.format = 'wrapped'
65-
}
66-
case 'wrapped': {
67-
if (format === 'wrapped' && result.format === 'wrapped') {
68-
return result
69-
}
70-
const sha = await shasum(result.object)
71-
if (sha !== oid) {
72-
throw new InternalError(
73-
`SHA check failed! Expected ${oid}, computed ${sha}`
74-
)
75-
}
76-
const { object, type } = GitObject.unwrap(result.object)
77-
result.type = type
78-
result.object = object
79-
result.format = 'content'
80-
}
81-
case 'content': {
82-
if (format === 'content') return result
83-
break
58+
if (result.format === 'deflated') {
59+
result.object = Buffer.from(await inflate(result.object))
60+
result.format = 'wrapped'
61+
}
62+
63+
if (result.format === 'wrapped') {
64+
if (format === 'wrapped' && result.format === 'wrapped') {
65+
return result
8466
}
85-
default: {
86-
throw new InternalError(`invalid format "${result.format}"`)
67+
const sha = await shasum(result.object)
68+
if (sha !== oid) {
69+
throw new InternalError(
70+
`SHA check failed! Expected ${oid}, computed ${sha}`
71+
)
8772
}
73+
const { object, type } = GitObject.unwrap(result.object)
74+
result.type = type
75+
result.object = object
76+
result.format = 'content'
8877
}
89-
/* eslint-enable no-fallthrough */
78+
79+
if (result.format === 'content') {
80+
if (format === 'content') return result
81+
return
82+
}
83+
84+
throw new InternalError(`invalid format "${result.format}"`)
9085
}

0 commit comments

Comments
 (0)