manshar/manshar

View on GitHub

Showing 82 of 82 total issues

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

      var CategoryResource = $resource(baseUrl + 'categories/:categoryId', {}, {
        get: {cache: true},
        query: {cache: true, isArray: true}
      });
Severity: Minor
Found in web-client/app/scripts/services/categoryService.js and 1 other location - About 40 mins to fix
web-client/app/scripts/services/imageService.js on lines 8..11

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

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

      var ImageResource = $resource(baseUrl + 'images/:imageId', {}, {
        get: {cache: true},
        query: {cache: true, isArray: true}
      });
Severity: Minor
Found in web-client/app/scripts/services/imageService.js and 1 other location - About 40 mins to fix
web-client/app/scripts/services/categoryService.js on lines 8..11

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

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 update has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        update: function (params, data, optSuccess, optError, optConfig) {
Severity: Minor
Found in web-client/app/scripts/services/articleService.js - About 35 mins to fix

    Function createNewComment has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        var createNewComment = function(srcElement, scope, container, offsetTop, guidAttribute) {
    Severity: Minor
    Found in web-client/app/scripts/directives/anchoredComments.js - About 35 mins to fix

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

            swal({
              title: 'هل أنت متأكد من حذف الفئة؟',
              text: 'لن تستطيع استعادة الفئة المحذوفة.',
              type: 'warning',
              showCancelButton: true,
      web-client/app/scripts/controllers/editArticleController.js on lines 154..163
      web-client/app/scripts/controllers/profileController.js on lines 63..72

      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 3 locations. Consider refactoring.
      Open

            swal({
              title: 'متأكد من حذف المقال؟',
              text: 'لن تستطيع استعادة المقال بعد الحذف.',
              type: 'warning',
              showCancelButton: true,
      Severity: Minor
      Found in web-client/app/scripts/controllers/editArticleController.js and 2 other locations - About 35 mins to fix
      web-client/app/scripts/controllers/admin/manageCategoriesCtrl.js on lines 25..34
      web-client/app/scripts/controllers/profileController.js on lines 63..72

      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 3 locations. Consider refactoring.
      Open

            swal({
              title: 'متأكد من حذف المقال؟',
              text: 'لن تستطيع استعادة المقال بعد الحذف.',
              type: 'warning',
              showCancelButton: true,
      Severity: Minor
      Found in web-client/app/scripts/controllers/profileController.js and 2 other locations - About 35 mins to fix
      web-client/app/scripts/controllers/admin/manageCategoriesCtrl.js on lines 25..34
      web-client/app/scripts/controllers/editArticleController.js on lines 154..163

      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

      Method abs_url_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def abs_url_for *attributes
            attributes.each do |attr_name|
              define_method "#{attr_name}_abs_url" do |size = nil|
      
                image = self.send(attr_name)
      Severity: Minor
      Found in backend/app/models/concerns/utils.rb - About 35 mins 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

      Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          # make sure user is authorized
          unless @resource
            return render json: {
              success: false,
      Severity: Minor
      Found in backend/app/controllers/api/v1/passwords_controller.rb - About 35 mins 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 5 locations. Consider refactoring.
      Open

                } else if(scope.category) {
                  CategoryArticle.query({
                    'categoryId': scope.category.id,
                    'page': ++page,
                    'order': scope.order
      Severity: Major
      Found in web-client/app/scripts/directives/loadMoreData.js and 4 other locations - About 35 mins to fix
      web-client/app/scripts/directives/loadMoreData.js on lines 81..105
      web-client/app/scripts/directives/loadMoreData.js on lines 87..105
      web-client/app/scripts/directives/loadMoreData.js on lines 93..105
      web-client/app/scripts/directives/loadMoreData.js on lines 99..105

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

      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 5 locations. Consider refactoring.
      Open

                  } else if(scope.state === 'recommended') {
                    UserRecommendation.query({
                      'userId': scope.profile.id,
                      'page': ++page,
                      'order': scope.order
      Severity: Major
      Found in web-client/app/scripts/directives/loadMoreData.js and 4 other locations - About 35 mins to fix
      web-client/app/scripts/directives/loadMoreData.js on lines 74..111
      web-client/app/scripts/directives/loadMoreData.js on lines 81..105
      web-client/app/scripts/directives/loadMoreData.js on lines 93..105
      web-client/app/scripts/directives/loadMoreData.js on lines 99..105

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

      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 5 locations. Consider refactoring.
      Open

                  } else if(scope.state === 'drafts') {
                    UserDraft.query({
                      'userId': scope.profile.id,
                      'page': ++page,
                      'order': scope.order
      Severity: Major
      Found in web-client/app/scripts/directives/loadMoreData.js and 4 other locations - About 35 mins to fix
      web-client/app/scripts/directives/loadMoreData.js on lines 74..111
      web-client/app/scripts/directives/loadMoreData.js on lines 81..105
      web-client/app/scripts/directives/loadMoreData.js on lines 87..105
      web-client/app/scripts/directives/loadMoreData.js on lines 93..105

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

      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 5 locations. Consider refactoring.
      Open

                  } else if(scope.state === 'discussions') {
                    UserComment.query({
                      'userId': scope.profile.id,
                      'page': ++page,
                      'order': scope.order
      Severity: Major
      Found in web-client/app/scripts/directives/loadMoreData.js and 4 other locations - About 35 mins to fix
      web-client/app/scripts/directives/loadMoreData.js on lines 74..111
      web-client/app/scripts/directives/loadMoreData.js on lines 81..105
      web-client/app/scripts/directives/loadMoreData.js on lines 87..105
      web-client/app/scripts/directives/loadMoreData.js on lines 99..105

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

      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 5 locations. Consider refactoring.
      Open

                  if(scope.state === 'published') {
                    UserArticle.query({
                      'userId': scope.profile.id,
                      'page': ++page,
                      'order': scope.order
      Severity: Major
      Found in web-client/app/scripts/directives/loadMoreData.js and 4 other locations - About 35 mins to fix
      web-client/app/scripts/directives/loadMoreData.js on lines 74..111
      web-client/app/scripts/directives/loadMoreData.js on lines 87..105
      web-client/app/scripts/directives/loadMoreData.js on lines 93..105
      web-client/app/scripts/directives/loadMoreData.js on lines 99..105

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

      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

      Avoid too many return statements within this function.
      Open

              return time + ' دقيقة للقراءة';
      Severity: Major
      Found in web-client/app/scripts/filters/timeToRead.js - About 30 mins to fix

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

            development: {
              src: src + '/views/**/*.html',
              dest: development + '/scripts',
              module: 'webClientApp',
              filename: 'cachedTemplates.js',
        Severity: Minor
        Found in web-client/gulp/config.js and 1 other location - About 30 mins to fix
        web-client/gulp/config.js on lines 196..204

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

        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

            production: {
              src: src + '/views/**/*.html',
              dest: production + '/scripts',
              module: 'webClientApp',
              filename: 'cachedTemplates.js',
        Severity: Minor
        Found in web-client/gulp/config.js and 1 other location - About 30 mins to fix
        web-client/gulp/config.js on lines 187..195

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

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

          def change
            add_column :articles, :user_name, :string
            add_column :articles, :topic_title, :string
            add_column :articles, :category_color, :string
        
        

        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

                before = User.where(
                  order_param + ' < ? OR ' + order_param + ' = ? AND id < ?',
                    user.try(order_param), user.try(order_param), user.id)
                    .where.not(id: user).where.not(published_articles_count: 0)
        Severity: Minor
        Found in backend/app/controllers/api/v1/users_controller.rb and 1 other location - About 20 mins to fix
        backend/app/controllers/api/v1/users_controller.rb on lines 21..24

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

        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

                after = User.where(
                  order_param + ' > ? OR ' + order_param + ' = ? AND id > ?',
                    user.try(order_param), user.try(order_param), user.id)
                    .where.not(id: user).where.not(published_articles_count: 0)
        Severity: Minor
        Found in backend/app/controllers/api/v1/users_controller.rb and 1 other location - About 20 mins to fix
        backend/app/controllers/api/v1/users_controller.rb on lines 28..31

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

        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