superdesk/superdesk-client-core

View on GitHub

Showing 3,654 of 3,654 total issues

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

            scope.setStageInfo = function(_id) {
                var item = scope.editGroups[_id];

                if (!item.type) {
                    item._id = _id;
Severity: Major
Found in scripts/apps/monitoring/directives/AggregateSettings.ts and 1 other location - About 3 hrs to fix
scripts/apps/monitoring/directives/AggregateSettings.ts on lines 173..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 101.

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

        link: function(scope, elem, attrs) {
            var ARROW_UP = 38, ARROW_DOWN = 40, ENTER = 13;

            scope.selected = null;
            scope.search = null;
Severity: Major
Found in scripts/apps/desks/directives/UserSelectList.ts - About 3 hrs to fix

    Function MultiActionBar has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function MultiActionBar(
        asset,
        multi,
        superdesk,
        keyboardManager,
    Severity: Major
    Found in scripts/apps/search/directives/MultiActionBar.ts - About 3 hrs to fix

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

          render() {
              const {children} = this.props;
      
              const childrenEmpty =
                  typeof children === 'undefined'
      Severity: Major
      Found in scripts/core/ui/components/drop-zone-3.tsx - About 3 hrs to fix

        Function handleKeyCommand has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            handleKeyCommand(command) {
                const author = getCurrentAuthor();
                const {editorState, onChange, singleLine, suggestingMode} = this.props;
                const {
                    onCreateSplitParagraphSuggestion,
        Severity: Major
        Found in scripts/core/editor3/components/Editor3Component.tsx - About 3 hrs to fix

          Function IngestRoutingContent has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          export function IngestRoutingContent(api, notify, modal, contentFilters, $filter) {
              return {
                  templateUrl: 'scripts/apps/ingest/views/settings/ingest-routing-content.html',
                  link: function(scope) {
                      let _orig = null, _origRule = null, _new = false;
          Severity: Minor
          Found in scripts/apps/ingest/directives/IngestRoutingContent.ts - 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 AuthoringDirective has 26 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              superdesk,
              authoringWorkspace: AuthoringWorkspaceService,
              notify,
              desks,
              authoring,
          Severity: Major
          Found in scripts/apps/authoring/authoring/directives/AuthoringDirective.ts - About 3 hrs to fix

            Function SaveSearch has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            export function SaveSearch($location, asset, api, notify, $rootScope) {
                return {
                    templateUrl: asset.templateUrl('apps/search/views/save-search.html'),
                    link: function(scope, _elem) {
                        scope.edit = null;
            Severity: Minor
            Found in scripts/apps/search/directives/SaveSearch.ts - 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 getRightRangeAndTextForStyle has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
            Open

            function getRightRangeAndTextForStyle(editorState, style) {
                /* eslint-disable complexity */
                const type = getHighlightTypeFromStyleName(style);
                const selection = editorState.getSelection();
                const content = editorState.getCurrentContent();
            Severity: Minor
            Found in scripts/core/editor3/helpers/highlights.ts - 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 ContactList has 81 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function ContactList(
                $timeout,
                $filter,
                search,
                datetime,
            Severity: Major
            Found in scripts/apps/contacts/directives/ContactList.ts - About 3 hrs to fix

              Function DeskeditBasic has 81 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function DeskeditBasic(desks, WizardHandler, metadata, $filter, notify) {
                  return {
                      link: function(scope) {
                          scope.limits = limits;
                          scope.deskTypes = [];
              Severity: Major
              Found in scripts/apps/desks/directives/DeskeditBasic.ts - About 3 hrs to fix

                Function constructor has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    constructor() {
                        this.list = element.all(by.repeater('dictionary in dictionaries'));
                        this.name = element(by.model('dictionary.name'));
                        this.languageId = element(by.model('dictionary.language_id'));
                
                
                Severity: Major
                Found in e2e/client/specs/helpers/dictionaries.ts - About 3 hrs to fix

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

                      render() {
                          const {gettext, longFormatDateTime, getRelativeOrAbsoluteDateTime} = superdeskApi.localization;
                          const {config} = superdeskApi.instance;
                          const actions = getDropdownItemsForActions(this.props.asset, this.props.actions);
                          const mimetype = getMimetypeHumanReadable(this.props.asset.mimetype);
                  Severity: Major
                  Found in scripts/extensions/sams/src/components/assets/assetListItem.tsx - About 3 hrs to fix

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

                        render() {
                            const {field, item, required} = this.props;
                            const value = item[field.key] || '';
                            const valueObj = item[field.key] ?? {};
                            const disabled = !item.is_active;
                    Severity: Major
                    Found in scripts/apps/vocabularies/components/VocabularyItemsViewEdit.tsx - About 3 hrs to fix

                      Function DictionaryConfigController has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function DictionaryConfigController($scope, dictionaries, session, modal, notify) {
                          $scope.dictionaries = null;
                          $scope.origDictionary = null;
                          $scope.dictionary = null;
                      
                      
                      Severity: Major
                      Found in scripts/apps/dictionaries/controllers/DictionaryConfigController.ts - About 3 hrs to fix

                        File get-bulk-actions.tsx has 300 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import {IArticle} from 'superdesk-api';
                        import {sdApi} from 'api';
                        import {dispatchInternalEvent} from 'core/internal-events';
                        import ng from 'core/services/ng';
                        import {getArticleLabel, gettext} from 'core/utils';
                        Severity: Minor
                        Found in scripts/apps/search/controllers/get-bulk-actions.tsx - About 3 hrs to fix

                          Function SearchMenuController has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export default function SearchMenuController(
                              $rootScope, $scope, $filter, $location, $route, searchProviderService, api, savedSearch,
                              privileges,
                          ) {
                              let providerLabels = {};
                          Severity: Major
                          Found in scripts/apps/search/controllers/SearchMenuController.ts - About 3 hrs to fix

                            Function link has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                    link: function(scope) {
                                        const PARAMETERS = getParameters();
                            
                                        scope.cvs = metadata.search_cvs;
                                        const urlParams = scope.urlParams || PARAMETERS;
                            Severity: Major
                            Found in scripts/apps/search/directives/SearchTags.ts - About 3 hrs to fix

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

                                      this.eventListenersToRemoveBeforeUnmounting.push(
                                          addWebsocketEventListener(
                                              'resource:updated',
                                              (event: IWebsocketMessage<IResourceUpdateEvent>) => {
                                                  const {resource, _id, fields} = event.extra;
                              Severity: Major
                              Found in scripts/apps/search/components/ItemListAngularWrapper.tsx and 2 other locations - About 3 hrs to fix
                              scripts/core/itemList/items-list-limited.tsx on lines 97..106
                              scripts/core/ArticlesListV2.tsx on lines 229..238

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

                              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

                                      this.eventListenersToRemoveBeforeUnmounting.push(
                                          addWebsocketEventListener(
                                              'resource:updated',
                                              (event: IWebsocketMessage<IResourceUpdateEvent>) => {
                                                  const {resource, _id, fields} = event.extra;
                              Severity: Major
                              Found in scripts/core/itemList/items-list-limited.tsx and 2 other locations - About 3 hrs to fix
                              scripts/apps/search/components/ItemListAngularWrapper.tsx on lines 224..233
                              scripts/core/ArticlesListV2.tsx on lines 229..238

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

                              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