Geovation/photos

View on GitHub

Showing 138 of 138 total issues

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

function convertFirebaseTimestampFieldsIntoDate(photo) {
  const newPhoto = _.cloneDeep(photo);
  _.forEach(newPhoto, (value, field) => {
    if (value.toDate) {
      newPhoto[field] = value.toDate();
Severity: Major
Found in functions/index.js and 1 other location - About 2 hrs to fix
src/features/firebase/dbFirebase.js on lines 133..141

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

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

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

function convertFirebaseTimestampFieldsIntoDate(photo) {
  const newPhoto = _.cloneDeep(photo);
  _.forEach(newPhoto, (value, field) => {
    if (value.toDate) {
      newPhoto[field] = value.toDate();
Severity: Major
Found in src/features/firebase/dbFirebase.js and 1 other location - About 2 hrs to fix
functions/index.js on lines 226..234

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

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

  render() {
    const props = { ...this.props };
    const field = {
      name: "brand",
      title: "Brand",
Severity: Minor
Found in src/components/PhotoPage/MultipleSelectControlTextFields.js - About 1 hr to fix

    Function uploadPhoto has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function uploadPhoto(data, imgSrc, onProgress) {
      const rtn = {};
      let canceled = false;
      let uploadTask;
      let resolve;
    Severity: Minor
    Found in src/features/firebase/dbFirebase.js - About 1 hr to fix

      Function hostMetadata has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function hostMetadata(req, res) {
        const BUCKET = config.FIREBASE.config.storageBucket;
        const SERVER_URL = config.metadata.serverUrl;
        const TW_SITE = config.metadata.twSite;
        const TW_CREATOR = config.metadata.twCreator;
      Severity: Minor
      Found in functions/index.js - About 1 hr to fix

        Function onAuthStateChanged has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const onAuthStateChanged = (fn) => {
          onUserChangeCallBackFn = fn;
          const firebaseStatusChange = (user) => {
            currentUser = user;
            if (config.USER.ENABLE_GRAVATAR_PROFILES && currentUser) {
        Severity: Minor
        Found in src/features/firebase/authFirebase.js - About 1 hr to fix

          Function updateStats has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            .onPublish(async (message, context) => {
              const stats = {
                totalUploaded: 0,
                moderated: 0,
                published: 0,
          Severity: Minor
          Found in functions/index.js - About 1 hr to fix

            Function renderTableBody has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              renderTableBody() {
                const { usersLeaderboard, classes, user } = this.props;
                const userId = user && user.id;
                sortArrayByObjectKey(
                  usersLeaderboard,
            Severity: Minor
            Found in src/components/Leaderboard/index.js - About 1 hr to fix

              Function render has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                render() {
                  // const { fullScreen, handleClose, classes } = this.props; //to use uncomment "line fullSreen={fullScreen}"
                  const { handleClose, classes } = this.props; //comment this and uncomment above line to use fullScreen T&C page
                  return (
                    <Dialog
              Severity: Minor
              Found in src/components/TermsDialog.js - About 1 hr to fix

                Function firebaseStatusChange has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  const firebaseStatusChange = (user) => {
                    currentUser = user;
                    if (config.USER.ENABLE_GRAVATAR_PROFILES && currentUser) {
                      gtagSetId(user.uid);
                      gtagEvent("Logged in", "User", user.uid);
                Severity: Minor
                Found in src/features/firebase/authFirebase.js - About 1 hr to fix

                  Function ProfileTextField has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const ProfileTextField = connect(mapStateToProps)(withStyles(styles)(function (props) {
                    const { user, className, fieldName, classes, maxLength, placeholder } = props;
                    const originalFieldValue = user[fieldName] || "";
                  
                    const [updating, setUpdating] = useState(false);
                  Severity: Minor
                  Found in src/components/ProfilePage.js - About 1 hr to fix

                    Function drawByMonth has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function drawByMonth(months, ctx) {
                          let sortedMonths = _.map(months, (amount, date) => {
                            return {
                              date: new Date(date),
                              amount,
                    Severity: Minor
                    Found in src/custom/components/ReportsPage.js - About 1 hr to fix

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

                        {
                          title: utils.customiseString("welcome", "Be part of the solution"),
                          img: (
                            <img
                              src={utils.customiseString("welcome", "croud.png")}
                      Severity: Major
                      Found in src/custom/welcomeSteps.js and 1 other location - About 1 hr to fix
                      src/custom/welcomeSteps.js on lines 21..34

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

                      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

                        {
                          title: utils.customiseString("welcome", "Global research"),
                          img: (
                            <img
                              src={utils.customiseString("welcome", "chart.png")}
                      Severity: Major
                      Found in src/custom/welcomeSteps.js and 1 other location - About 1 hr to fix
                      src/custom/welcomeSteps.js on lines 35..48

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

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

                        render() {
                          const {
                            photoSelected,
                            handleRejectClick,
                            handleApproveClick,
                      Severity: Minor
                      Found in src/components/CardComponent.js - About 1 hr to fix

                        Function render has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          render() {
                            const { classes } = this.props;
                        
                            return (
                              <PageWrapper label={config.PAGES.writeFeedback.label} handleClose={this.props.handleClose}>
                        Severity: Minor
                        Found in src/components/WriteFeedbackPage.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

                        Function render has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          render() {
                            const { classes } = this.props;
                            const gpsOffline = !this.context.geolocation.online;
                            const gpsDisabled = !this.context.geolocation.updated;
                        
                        
                        Severity: Minor
                        Found in src/components/MapPage/Map.js - About 1 hr to fix

                          Function GeolocationContextProvider has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const GeolocationContextProvider = (props) => {
                            const [geolocation, setGeolocation] = useState(new MapLocation());
                            const locationWatherId = useRef(null);
                          
                            useEffect(() => {
                          Severity: Minor
                          Found in src/store/GeolocationContext.js - About 1 hr to fix

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

                                      <DialogActions color="secondary">
                                        <Button
                                          className={classes.button}
                                          fullWidth
                                          variant="contained"
                            Severity: Major
                            Found in src/components/EmailVerifiedDialog.js and 1 other location - About 1 hr to fix
                            src/components/EmailVerifiedDialog.js on lines 179..189

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

                            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

                                      <DialogActions color="secondary">
                                        <Button
                                          className={classes.button}
                                          fullWidth
                                          color="secondary"
                            Severity: Major
                            Found in src/components/EmailVerifiedDialog.js and 1 other location - About 1 hr to fix
                            src/components/EmailVerifiedDialog.js on lines 140..150

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

                            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