iteratehq/react-native-iterate

View on GitHub

Showing 18 of 18 total issues

Function addSorting has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

var addSorting = (function() {
    'use strict';
    var cols,
        currentSort = {
            index: 0,
Severity: Minor
Found in coverage/lcov-report/sorter.js - About 6 hrs to fix

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 addSorting has 161 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var addSorting = (function() {
    'use strict';
    var cols,
        currentSort = {
            index: 0,
Severity: Major
Found in coverage/lcov-report/sorter.js - About 6 hrs to fix

    Function SurveyView has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    const SurveyView: (Props: Props) => JSX.Element = ({
      companyAuthToken,
      displayedSurveyResponseId,
      eventTraits,
      onDismiss,
    Severity: Minor
    Found in src/components/Survey.tsx - About 3 hrs to fix

    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 reducer has 79 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const reducer = (state: State = INITIAL_STATE, action: Action) => {
      switch (action.type) {
        case 'DISMISS':
          return {
            ...state,
    Severity: Major
    Found in src/redux.tsx - About 3 hrs to fix

      Function init has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      var jumpToCode = (function init() {
          // Classes of code we would like to highlight in the file view
          var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
      
          // Elements to highlight in the file listing view
      Severity: Major
      Found in coverage/lcov-report/block-navigation.js - About 2 hrs to fix

        Function App has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const App = () => {
          React.useEffect(() => {
            Iterate.init({
              apiKey: apiKey,
              safeArea: useSafeAreaInsets,
        Severity: Major
        Found in example/src/App.tsx - About 2 hrs to fix

          File redux.tsx has 252 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import type { EdgeInsets } from './types';
          import type {
            EventTraits,
            EventTraitsMap,
            PresentationStyle,
          Severity: Minor
          Found in src/redux.tsx - About 2 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (Iterate.surveyTextFont != null) {
                params.push(
                  `surveyTextFontPath=${
                    Platform.OS === 'android'
                      ? `file:///android_asset/fonts/${Iterate.surveyTextFont.filename}`
            Severity: Major
            Found in src/components/Survey.tsx and 1 other location - About 1 hr to fix
            src/components/Survey.tsx on lines 123..131

            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 74.

            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

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              if (Iterate.buttonFont != null) {
                params.push(
                  `buttonFontPath=${
                    Platform.OS === 'android'
                      ? `file:///android_asset/fonts/${Iterate.buttonFont.filename}`
            Severity: Major
            Found in src/components/Survey.tsx and 1 other location - About 1 hr to fix
            src/components/Survey.tsx on lines 113..121

            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 74.

            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

            Further Reading

            Method initializeFlipper has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
                if (FlipperUtils.shouldEnableFlipper(context)) {
                  final FlipperClient client = AndroidFlipperClient.getInstance(context);
            
                  client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));

              Function Prompt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              const Prompt: (Props: Props) => JSX.Element = ({
                dispatchShowSurvey,
                onDismiss,
                safeAreaInsets,
                survey,
              Severity: Minor
              Found in src/components/Prompt/index.tsx - About 1 hr to fix

              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 init has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

              var jumpToCode = (function init() {
                  // Classes of code we would like to highlight in the file view
                  var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
              
                  // Elements to highlight in the file listing view
              Severity: Minor
              Found in coverage/lcov-report/block-navigation.js - About 1 hr to fix

              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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    const authToken: string | null = await Storage.getItem(
                      Keys.authToken
                    ).catch((err) => {
                      throw `Error getting authToken from secure storage: ${err}`;
                    });
              Severity: Major
              Found in src/iterate.tsx and 1 other location - About 1 hr to fix
              src/iterate.tsx on lines 190..194

              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 56.

              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

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    const lastUpdated: string | null = await Storage.getItem(
                      Keys.lastUpdated
                    ).catch((err) => {
                      throw `Error getting last updated timestamp from secure storage: ${err}`;
                    });
              Severity: Major
              Found in src/iterate.tsx and 1 other location - About 1 hr to fix
              src/iterate.tsx on lines 179..183

              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 56.

              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

              Further Reading

              Function enableUI has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function enableUI() {
                      var i,
                          el,
                          ithSorter = function ithSorter(i) {
                              var col = cols[i];
              Severity: Minor
              Found in coverage/lcov-report/sorter.js - About 1 hr to fix

                Function setUserTraits has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const setUserTraits = (traits: UserTraits): SetUserTraits => {
                  const validTraits: UserTraitsContext = {};
                  Object.entries(traits).forEach(([key, value]) => {
                    switch (typeof value) {
                      case 'boolean':
                Severity: Minor
                Found in src/redux.tsx - About 1 hr to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  export const setEventTraits = (
                    traits: EventTraits,
                    responseId: number
                  ): SetEventTraits => ({
                    type: 'SET_EVENT_TRAITS',
                  Severity: Minor
                  Found in src/redux.tsx and 1 other location - About 35 mins to fix
                  src/redux.tsx on lines 175..182

                  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 47.

                  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

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  export const showPrompt = (
                    survey: Survey,
                    responseId?: number
                  ): ShowPromptAction => ({
                    type: 'SHOW_PROMPT',
                  Severity: Minor
                  Found in src/redux.tsx and 1 other location - About 35 mins to fix
                  src/redux.tsx on lines 102..109

                  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 47.

                  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

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language