Code Smells Fix (Majors and Minors)
continuous-integration/drone/push Build is passing Details

pull/20/head
Louison PARANT 2 years ago
parent 3e0e3f6e6a
commit 12e8660fc1

@ -2,7 +2,7 @@ import Ingredient from "../../Models/Ingredient";
export default interface IIngredientService { export default interface IIngredientService {
getAllIngredient(): Promise<Ingredient[]>; getAllIngredient(): Promise<Ingredient[]>;
getIngredientById(id: Number): Promise<Ingredient | null>; getIngredientById(id: number): Promise<Ingredient | null>;
getIngredientByLetter(id: String): Promise<Ingredient[]>; getIngredientByLetter(id: string): Promise<Ingredient[]>;
getfilteredIngredient(prompt: String): Promise<Ingredient[]>; getfilteredIngredient(prompt: string): Promise<Ingredient[]>;
} }

@ -17,7 +17,7 @@ export default class IngredientService implements IIngredientService {
} }
async getIngredientById(id: Number): Promise<Ingredient | null>{ async getIngredientById(id: number): Promise<Ingredient | null>{
try { try {
const response = await axios.get(`${this.API_URL}/${id}`); const response = await axios.get(`${this.API_URL}/${id}`);
return response.data as Ingredient; return response.data as Ingredient;
@ -26,7 +26,7 @@ export default class IngredientService implements IIngredientService {
} }
} }
async getIngredientByLetter(letter: String): Promise<any>{ async getIngredientByLetter(letter: string): Promise<any>{
try { try {
const response = await axios.get(`${this.API_URL}/letter/${letter}`); const response = await axios.get(`${this.API_URL}/letter/${letter}`);
return response.data as Ingredient[]; return response.data as Ingredient[];
@ -35,7 +35,7 @@ export default class IngredientService implements IIngredientService {
} }
} }
async getfilteredIngredient(prompt: String): Promise<Ingredient[]> { async getfilteredIngredient(prompt: string): Promise<Ingredient[]> {
try { try {
const response = await axios.get(`${this.API_URL}/filter/${prompt}`); const response = await axios.get(`${this.API_URL}/filter/${prompt}`);
return response.data as Ingredient[]; return response.data as Ingredient[];

@ -2,5 +2,5 @@ import Recipes from "../../Models/Recipes";
export default interface IRecipesService { export default interface IRecipesService {
getAllRecipes(): Promise<Recipes[]>; getAllRecipes(): Promise<Recipes[]>;
getRecipeById(id: Number): Promise<Recipes | null>; getRecipeById(id: number): Promise<Recipes | null>;
} }

@ -17,7 +17,7 @@ export default class RecipesService implements IRecipesService {
} }
async getRecipeById(id: Number): Promise<Recipes | null>{ async getRecipeById(id: number): Promise<Recipes | null>{
try { try {
const response = await axios.get(`${this.API_URL}/${id}`); const response = await axios.get(`${this.API_URL}/${id}`);
console.log(response); console.log(response);

@ -1,10 +1,10 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import {StyleSheet,Pressable, Text, View, Image} from 'react-native'; import {StyleSheet,Pressable, Text, View} from 'react-native';
import Separator from '../components/Separator'; import Separator from '../components/Separator';
import ColorContext from '../theme/ColorContext'; import ColorContext from '../theme/ColorContext';
interface foodElementImageProps { interface FoodElementTextProps {
title : string title : string
} }

@ -1,15 +1,12 @@
import React from 'react'; import React from 'react';
import {StyleSheet,Pressable, Text, View, Image} from 'react-native'; import {StyleSheet,Pressable, Text, View} from 'react-native';
import Separator from '../components/Separator';
interface FoodElementTextSimpleProps {
interface foodElementTextProps {
title: string title: string
} }
export default function FoodElementTextSimple(props: foodElementTextProps) { export default function FoodElementTextSimple(props: FoodElementTextSimpleProps) {
return ( return (
<Pressable style={styles.button}> <Pressable style={styles.button}>
<View style={styles.container}> <View style={styles.container}>

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import {StyleSheet, Text, TextInput, View, Image, FlatList} from 'react-native'; import {StyleSheet, Text, View, Image} from 'react-native';
type TitleProps = { type TitleProps = {
title: string title: string

@ -1,8 +1,6 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import {StyleSheet, Text, TextInput, View, Image, FlatList} from 'react-native'; import {StyleSheet, Image} from 'react-native';
import ValidateButton from './ValidateButton'; import {MultipleSelectList} from 'react-native-dropdown-select-list'
import HeaderFlatList from './HeaderFlatList';
import { MultipleSelectList, SelectList } from 'react-native-dropdown-select-list'
import ColorContext from '../theme/ColorContext'; import ColorContext from '../theme/ColorContext';
type ListProps = { type ListProps = {

@ -1,8 +1,6 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import {StyleSheet, Text, TextInput, View, Image, FlatList, Pressable} from 'react-native'; import {StyleSheet, Image} from 'react-native';
import ValidateButton from './ValidateButton'; import {MultipleSelectList} from 'react-native-dropdown-select-list'
import HeaderFlatList from './HeaderFlatList';
import { MultipleSelectList, SelectList } from 'react-native-dropdown-select-list'
import ColorContext from '../theme/ColorContext'; import ColorContext from '../theme/ColorContext';
type ListProps = { type ListProps = {

@ -1,6 +1,5 @@
import {React, useState} from 'react'; import {React, useState} from 'react';
import {StyleSheet, Text, TextInput, View, Image, Pressable} from 'react-native'; import {StyleSheet, Text, View, Image, Pressable} from 'react-native';
import ValidateButton from './ValidateButton';
import ListWithoutSelect from './ListWithoutSelect'; import ListWithoutSelect from './ListWithoutSelect';
type ProfileProps = { type ProfileProps = {

@ -1,18 +1,18 @@
import React from 'react'; import React from 'react';
import {StyleSheet,Pressable, Text, View, Image, SafeAreaView, ScrollView} from 'react-native'; import {StyleSheet, Pressable, Text, View, Image, ScrollView} from 'react-native';
import brochette from '../assets/images/brochette.png'; import brochette from '../assets/images/brochette.png';
import Union_left from '../assets/images/Union_left.png'; import Union_left from '../assets/images/Union_left.png';
import Union_right from '../assets/images/Union_right.png'; import Union_right from '../assets/images/Union_right.png';
import background from '../assets/images/Background.png'; import background from '../assets/images/Background.png';
interface recipeElementProps { interface RecipeElementProps {
number: string number: string
title: string title: string
textList: string[] textList: string[]
description: string description: string
} }
export default function RecipeElement(props: recipeElementProps) { export default function RecipeElement(props: RecipeElementProps) {
return ( return (
<Pressable style={styles.button}> <Pressable style={styles.button}>
<View style={styles.view}> <View style={styles.view}>

@ -1,17 +1,17 @@
import React from 'react'; import React from 'react';
import {StyleSheet,Pressable, Text, View, Image} from 'react-native'; import {StyleSheet, Text, View, Image} from 'react-native';
import brochette from '../assets/images/brochette.png'; import brochette from '../assets/images/brochette.png';
import background from '../assets/images/Background.png'; import background from '../assets/images/Background.png';
interface recipeElementReduceProps { interface RecipeElementReduceProps {
number : number number : number
title : string title : string
image : string | null image : string | null
duration : string duration : string
} }
export default function RecipeElementReduce(props: recipeElementReduceProps) { export default function RecipeElementReduce(props: RecipeElementReduceProps) {
return ( return (
<View style={styles.button}> <View style={styles.button}>
<View style={styles.view}> <View style={styles.view}>

@ -1,6 +1,5 @@
import React, { useContext, useState } from 'react'; import React, { useContext, useState } from 'react';
import { View, Text, TouchableOpacity, Image, Pressable } from 'react-native'; import { View, Text, TouchableOpacity, Image, Pressable, GestureResponderEvent, StyleSheet } from 'react-native';
import { GestureResponderEvent, StyleSheet } from 'react-native';
import { BlurView } from 'expo-blur'; import { BlurView } from 'expo-blur';
import ThemeContext from '../theme/ThemeContext'; import ThemeContext from '../theme/ThemeContext';
import ColorContext from '../theme/ColorContext'; import ColorContext from '../theme/ColorContext';

@ -1,10 +1,9 @@
import React, { useContext } from 'react'; import React, { useContext } from 'react';
import { Image, Text, StyleSheet } from 'react-native'; import { Image, StyleSheet } from 'react-native';
import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { createNativeStackNavigator } from '@react-navigation/native-stack';
import HomePage from '../screens/HomePage'; import HomePage from '../screens/HomePage';
import Profiles from '../screens/Profiles'; import Profiles from '../screens/Profiles';
import CreateProfile from '../screens/CreateProfile';
import ModifyProfile from '../screens/ModifyProfile'; import ModifyProfile from '../screens/ModifyProfile';
import ThemeContext from '../theme/ThemeContext'; import ThemeContext from '../theme/ThemeContext';
import ColorContext from '../theme/ColorContext'; import ColorContext from '../theme/ColorContext';

@ -32,7 +32,7 @@ export default function FiltersSelection(props) {
const dieProfiles = [{value: "Porkless"}, {value: "Pescatarian"}] const dieProfiles = [{value: "Porkless"}, {value: "Pescatarian"}]
function isInProfileDiets(element, index, array) { function isInProfileDiets(element, index, array) {
var retType = true let retType = true
dieProfiles.forEach(function (diets) { dieProfiles.forEach(function (diets) {
if(diets.value==element.value){ if(diets.value==element.value){
retType = false retType = false

@ -1,7 +1,6 @@
import React, { useEffect, useState, useContext } from 'react'; import React, { useEffect, useState, useContext } from 'react';
import { View, StyleSheet, Text, Image, Pressable, ActivityIndicator, FlatList, ScrollView, useWindowDimensions } from 'react-native'; import { View, StyleSheet, Text, Image, Pressable, ActivityIndicator, FlatList, ScrollView, useWindowDimensions } from 'react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context'; import { SafeAreaProvider } from 'react-native-safe-area-context';
import TopBar from '../components/TopBar';
import { Searchbar } from 'react-native-paper'; import { Searchbar } from 'react-native-paper';
import FoodElementText from '../components/FoodElementText'; import FoodElementText from '../components/FoodElementText';
import CustomButton from '../components/CustomButton'; import CustomButton from '../components/CustomButton';

@ -17,12 +17,6 @@ export default function Profiles({navigation, props}) {
const allJackie = [{value: "Tomato"}, {value: "Relic"}] const allJackie = [{value: "Tomato"}, {value: "Relic"}]
const dieJackie = [{value: "Porkless"}, {value: "Vegetarian"}] const dieJackie = [{value: "Porkless"}, {value: "Vegetarian"}]
const allGoro = []
const dieGoro = [{value: "Pescatarian"}]
const allViktor = [{value: "Pasta"}, {value: "Fish"}]
const dieViktor = [{value: "Dairy free"}, {value: "Vegan"}]
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [opacity, setOpacity] = useState(1); const [opacity, setOpacity] = useState(1);
const raisePopUp = () => { const raisePopUp = () => {

@ -3,7 +3,6 @@ import { View, StyleSheet, Text, ScrollView, useWindowDimensions} from 'react-na
import { SafeAreaProvider } from 'react-native-safe-area-context'; import { SafeAreaProvider } from 'react-native-safe-area-context';
import RecipeElementReduce from '../components/RecipeElementReduce'; import RecipeElementReduce from '../components/RecipeElementReduce';
import AllergiesTab from '../components/ListWithoutSelect';
import RecipesService from '../Services/Recipes/RecipesServices'; import RecipesService from '../Services/Recipes/RecipesServices';
import Recipes from '../Models/Recipes'; import Recipes from '../Models/Recipes';
import { LinearGradient } from 'expo-linear-gradient'; import { LinearGradient } from 'expo-linear-gradient';

@ -71,7 +71,7 @@ export default function RecipeSuggestion(props) {
} }
else{ else{
setMaxCpt(ingredientList.length+ingredientList.length%4) setMaxCpt(ingredientList.length+ingredientList.length%4)
var cpt=ingredientList.length-(ingredientList.length%4) let cpt=ingredientList.length-(ingredientList.length%4)
setMinCpt(cpt) setMinCpt(cpt)
} }
} }

Loading…
Cancel
Save