Showing 189 of 190 total issues
Function fetchAsync
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
func fetchAsync(sourceUrl: String, targetFilePath: String, collector: FetchResultCollector) {
let targetFileURL = URL(fileURLWithPath: targetFilePath)
let fileManager = FileManager.default
- 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
Function Intro
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const Intro = ({ route, navigation }: IntroProps): ReactElement => {
const { updateSettings } = useContext(AppContext)
const [currentSlide, setCurrentSlide] = useState(0)
const { width } = useWindowDimensions()
const { t } = useTranslation<['intro', 'settings']>(['intro', 'settings'])
- 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
Function useUserLocation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const useUserLocation = ({ requestPermissionInitially }: UseUserLocationProps): UseUserLocationReturn => {
const [locationState, setLocationState] = useState<LocationStateType>(initialState)
const showSnackbar = useSnackbar()
const { t } = useTranslation()
- 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
Function queryStringFromRouteInformation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export const queryStringFromRouteInformation = (
routeInformation: NonNullableRouteInformationType,
): string | undefined => {
const queryParams = []
if (routeInformation.route === POIS_ROUTE) {
- 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
Function loadWithCache
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const loadWithCache = async <T extends object>({
cityCode,
languageCode,
isAvailable,
getFromDataContainer,
- 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
Function SettingItem
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const SettingItem = (props: SettingItemProps): ReactElement => {
const { title, description, onPress, value, hasBadge, hasSwitch, bigTitle, role } = props
const { t } = useTranslation('settings')
return (
Function buildConfigAssets
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const buildConfigAssets = (): AssetsType => {
const assetsName = buildConfig().assets
if (assetsName === INTEGREAT_ASSETS) {
return {
Function LanguageSelector
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
const LanguageSelector = (props: LanguageSelectorProps): ReactElement => {
const { isHeaderActionItem, languageChangePaths, languageCode, inKebabMenu = false, closeSidebar } = props
const activeItemCode = languageCode
const { t } = useTranslation('layout')
Function formatDevelopmentNotes
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const formatDevelopmentNotes = (params: { notes: NoteType[]; language: string; platforms: string[] }) => {
const { notes, language, platforms } = params
const emptyNotesMap = {
common: [] as NoteType[],
android: [] as NoteType[],
Function handleSubmit
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleSubmit = () => {
setSendingStatus('sending')
const request = async () => {
const feedbackEndpoint = createFeedbackEndpoint(await determineApiUrl())
Function toICal
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
toICal(baseUrl: string, appName: string, recurring: boolean): string {
const { title, location, path, date, excerpt, lastUpdate } = this
const url = `${baseUrl}${path}`
const uid = v5(`${url}/${formatDateICal(lastUpdate)}`, v5.URL)
const timezone = date.startDate.zone.name
Function storeCategories
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
async storeCategories(categoriesMap: CategoriesMapModel, context: DatabaseContext): Promise<void> {
const categoryModels = categoriesMap.toArray()
const jsonModels = categoryModels.map(
(category: CategoryModel): ContentCategoryJsonType => ({
root: category.isRoot(),
Function CityNotCooperating
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
const CityNotCooperating = (): ReactElement | null => {
const { t } = useTranslation('cityNotCooperating')
const [isCopied, setIsCopied] = useState<boolean>(false)
const template = buildConfig().featureFlags.cityNotCooperatingTemplate
const CityNotCooperatingIcon = buildConfigAssets().CityNotCooperatingIcon
Function checkCalendarsAndExportEvent
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
const checkCalendarsAndExportEvent = async (): Promise<void> => {
const iosPermission = [PERMISSIONS.IOS.CALENDARS]
const androidPermissions = [PERMISSIONS.ANDROID.READ_CALENDAR, PERMISSIONS.ANDROID.WRITE_CALENDAR]
const permission = await requestMultiple(Platform.OS === 'ios' ? iosPermission : androidPermissions)
const permissionDenied = Object.values(permission).some(permission => ['limited', 'blocked'].includes(permission))
Function pathnameFromRouteInformation
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const pathnameFromRouteInformation = (routeInformation: NonNullableRouteInformationType): string => {
if (
routeInformation.route === JPAL_TRACKING_ROUTE ||
routeInformation.route === LICENSES_ROUTE ||
routeInformation.route === CONSENT_ROUTE
Function log
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const log = async (message: string, level: SeverityLevel = 'debug'): Promise<void> => {
try {
const Sentry = await loadSentry()
if (sentryEnabled()) {
Sentry.addBreadcrumb({ message, level })
Identical blocks of code found in 2 locations. Consider refactoring. Open
new EndpointBuilder<ParamsType, ChatMessageModel>(CHAT_ENDPOINT_NAME)
.withParamsToUrlMapper(
(params: ParamsType): string =>
`${baseUrl}/api/${API_VERSION}/${params.city}/${params.language}/${CHAT_ENDPOINT_NAME}/${params.deviceId}/`,
)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 57.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
new EndpointBuilder<ParamsType, Array<ChatMessageModel>>(CHAT_ENDPOINT_NAME)
.withParamsToUrlMapper(
(params: ParamsType): string =>
`${baseUrl}/api/${API_VERSION}/${params.city}/${params.language}/${CHAT_ENDPOINT_NAME}/${params.deviceId}/`,
)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 57.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function moveReleaseNotes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const moveReleaseNotes = async ({ newVersionName, deliverinoPrivateKey, owner, repo, branch }: Options) => {
const appOctokit = await authenticate({ deliverinoPrivateKey, owner, repo })
const {
data: { commit },
} = await appOctokit.repos.getBranch({ owner, repo, branch })
- 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
Function MobileBanner
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const MobileBanner = (): ReactElement | null => {
const { value, updateLocalStorageItem } = useLocalStorage<string | null>({ key: 'showBanner', initialValue: null })
const isVisible = !value || DateTime.fromISO(value).plus({ months: 3 }) < DateTime.now()
const [isInstalled] = useState<boolean>(false) // This is always false because we can't know if app is installed or not before running the deep-link
const { icons, appName, apps, hostName } = buildConfig()
- 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"