ts/components/wallet/card/CardComponent.tsx
File CardComponent.tsx
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
/**
* Component rendering a credit card,
* with different appearences based on
* the props passed
*/
Function renderTopRightCorner
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private renderTopRightCorner() {
if (this.props.type === "Preview" || this.props.type === "Picking") {
const { wallet } = this.props;
return (
<View style={styles.cardLogo}>
Function renderBody
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private renderBody(creditCard: CreditCard) {
const { type } = this.props;
if (type === "Preview") {
return null;
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public render(): React.ReactNode {
const { wallet } = this.props;
const hasFlatBottom =
this.props.type === "Preview" || this.props.type === "Header";
Function renderTopRightCorner
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
private renderTopRightCorner() {
if (this.props.type === "Preview" || this.props.type === "Picking") {
const { wallet } = this.props;
return (
<View style={styles.cardLogo}>
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Consider simplifying this complex logical expression. Open
Open
if (this.props.type === "Header") {
const {
hideFavoriteIcon,
isFavorite,
onSetFavorite,
Consider simplifying this complex logical expression. Open
Open
if (
(this.props.type === "Full" || this.props.type === "Header") &&
this.props.onSetFavorite !== undefined &&
this.props.isFavorite !== undefined &&
!pot.isLoading(this.props.isFavorite) &&