znamenica/dneslov

View on GitHub

Showing 2,171 of 2,171 total issues

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

   getDescription() {
      return this.props.short_name + " " +
             this.props.names.reduce((res, x) => { return res + " " + x.name_text }, "") +
             this.props.titles.reduce((res, x) => { return res + " " + x.text }, "")
   }
Severity: Major
Found in app/components/Picture.jsx and 1 other location - About 3 hrs to fix
app/components/Eventee.jsx on lines 175..179

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

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

   getDescription() {
      return this.props.short_name + " " +
             this.props.names.reduce((res, x) => { return res + " " + x.name_text }, "") +
             this.props.titles.reduce((res, x) => { return res + " " + x.text }, "")
   }
Severity: Major
Found in app/components/Eventee.jsx and 1 other location - About 3 hrs to fix
app/components/Picture.jsx on lines 176..180

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

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

   def validate_each(record, attribute, value)
      options.each do |(type, sub_options)|
         value_in =
            case type
            when :width, :height
Severity: Minor
Found in app/validators/size_validator.rb - 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

Class CommonController has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

class Admin::CommonController < ApplicationController
   include ::Auth
   include ::Pundit::Authorization

   before_action :authenticate_user!, except: %i(dashboard)
Severity: Minor
Found in app/controllers/admin/common_controller.rb - About 3 hrs to fix

    Class ImageSyncService has 29 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ImageSyncService
       attr_reader :targets, :source, :storage, :asset_path
    
       def initialize source: nil, targets: [], asset_path: nil, storage: nil
          @source = source # path
    Severity: Minor
    Found in app/services/image_sync_service.rb - About 3 hrs to fix

      DynamicField has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @mixin(Subscribed)
      @mixin(Validation)
      @mixin(ValueToObject)
      @mixin(RepathTo)
      export default class DynamicField extends Component {
      Severity: Minor
      Found in app/components/DynamicField.jsx - About 3 hrs to fix

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

                       <img
                          alt={this.props.title}
                          src={this.props.thumb}
                          className={this.props.wrapperClassName}
                          data-index={this.props.index}
        Severity: Major
        Found in app/components/Image.jsx and 1 other location - About 3 hrs to fix
        app/components/PureImage.jsx on lines 41..47

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

        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

                 !this.state.errored && <img
                    alt={this.props.alt}
                    src={this.props.src}
                    className={this.props.wrapperClassName}
                    data-index={this.props.index}
        Severity: Major
        Found in app/components/PureImage.jsx and 1 other location - About 3 hrs to fix
        app/components/Image.jsx on lines 87..93

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

        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

        Assignment Branch Condition size for validate_each is too high. [45.32/30]
        Open

           def validate_each(record, attribute, value)
              o = plain_options
              code = record.alphabeth_code.to_s.to_sym
              res = Languageble::MATCH_TABLE[ code ]
              if res

        This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

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

              year_date: {
                 kind: 'text',
                 title: 'Дата в году',
                 placeholder: 'Введи дату в году',
                 data: { length: '7' },
        Severity: Major
        Found in app/components/memoMeta.jsx and 1 other location - About 3 hrs to fix
        app/components/readingMeta.jsx on lines 34..51

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

        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

              year_date: {
                 kind: 'text',
                 title: 'Годовая дата',
                 placeholder: 'Введи годовую дату',
                 data: { length: '7' },
        Severity: Major
        Found in app/components/readingMeta.jsx and 1 other location - About 3 hrs to fix
        app/components/memoMeta.jsx on lines 101..118

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

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

        export function renderElement(element, meta) {
           console.debug("[renderElement] << element:", element, "meta:", meta)
        
           let mapped = Object.getOwnPropertyNames(meta).reduce((metaResult, nameIn) => {
              let forIn = meta[nameIn].for,
        Severity: Major
        Found in app/components/render.jsx - About 3 hrs to fix

          Method total_size has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

             def total_size
                model = self.name.constantize
                rela = self.except(:limit, :offset)
                return totals(rela) #TODO
                pure = rela.except(:group, :order, :select, :joins, :left_outer_joins)
          Severity: Major
          Found in app/models/concerns/total_size.rb - About 3 hrs to fix

            Method included has 78 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

               def self.included base
                  base.class_eval do
                     has_many :titles, -> { title }, as: :describable, class_name: :Title
                     has_many :default_titles, -> { distinct }, through: :kind, source: :names, class_name: :Appellation
                     has_many :all_titles, ->(this) do
            Severity: Major
            Found in app/models/concerns/with_titles.rb - About 3 hrs to fix

              Method convert_icon_links_into_images has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                    def convert_icon_links_into_images
                       uri = URI.join(Rails.application.routes.url_helpers.root_url, "/api/v1/images/create.json")
              
                       links = Link.where(type: ["IconLink", "PhotoLink"]).find_each do |l|
                          url = Addressable::URI.parse(l.url).normalize.to_s
              Severity: Minor
              Found in app/lib/tasks.rb - 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

              Block has too many lines. [58/25]
              Open

                    base.class_eval do
                       has_many :descriptions, -> { where(type: :Description) }, as: :describable, dependent: :delete_all do
                          def for language_codes
                             where(language_code: language_codes).first
                          end

              This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

              Assignment Branch Condition size for base= is too high. [42.61/30]
              Open

                 def base= value
                    digits = value.mb_chars.downcase.to_s.gsub(/[^0-9]+/, '')
                    words = value.gsub(/[0-9]+/, '').split(/\s+/).select do |x|
                       x.mb_chars.downcase.to_s != x ;end
                    .map do |x|
              Severity: Minor
              Found in app/models/slug.rb by rubocop

              This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

              Method has too many lines. [27/15]
              Open

                 def set_base_year
                    types = %w(Resurrection Repose Writing Appearance Translation Sanctification)
              
                    event = self.events.to_a.sort_by { |x| (types.index(x.kind) || 100) }.first
              
              
              Severity: Minor
              Found in app/models/memory.rb by rubocop

              This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

              File PickMeUpCalendar.jsx has 294 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { Component } from 'react'
              import * as Pickmeup from 'pickmeup/js/pickmeup.js'
              import { merge } from 'merge-anything'
              import {julianEaster, orthodoxEaster} from 'date-easter'
              import PropTypes from 'prop-types'
              Severity: Minor
              Found in app/components/PickMeUpCalendar.jsx - About 3 hrs to fix

                File nameMeta.jsx has 293 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { matchLanguages, matchAlphabeths, matchLetters, matchEmptyObject, matchCodes, matchEmptyCollection } from 'matchers'
                import UrlRegexp from 'UrlRegexp'
                
                export const nameMeta = {
                   default: "text",
                Severity: Minor
                Found in app/components/nameMeta.jsx - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language