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

export function createChangeStyleSuggestion(style, active) {
    return {
        type: 'CREATE_CHANGE_STYLE_SUGGESTION',
        payload: {
            style: style,
Severity: Major
Found in scripts/core/editor3/actions/suggestions.tsx and 1 other location - About 1 hr to fix
scripts/core/editor3/actions/suggestions.tsx on lines 77..88

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

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.statusOptions = [
            {name: gettext('All'), value: null},
            {name: gettext('Active'), value: 'true'},
            {name: gettext('Inactive'), value: 'false'},
        ];
Severity: Major
Found in scripts/apps/contacts/services/ContactsService.ts and 1 other location - About 1 hr to fix
scripts/apps/contacts/services/ContactsService.ts on lines 53..57

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

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

            return _getAllProducts()
                .then((result) => {
                    self.products = result;
                    _.each(result._items, (product) => {
                        self.productLookup[product._id] = product;
Severity: Major
Found in scripts/apps/products/services/ProductsFactory.ts and 1 other location - About 1 hr to fix
scripts/apps/content-filters/controllers/FilterSearchController.ts on lines 48..53

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

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

    runFetchImages() {
        const formattedTags: Array<ITagInput> = this.formatTags(
            toServerFormat(this.props.data, superdesk),
        );

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

        constructor(props: IProps) {
            super(props);
            const {stringToNumber, filterKeys} = superdeskApi.helpers;
    
            this.state = {
    Severity: Minor
    Found in scripts/extensions/sams/src/components/assets/assetFilterPanel.tsx - About 1 hr to fix

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

          render() {
              const {availableFields} = this.props;
      
              return (
                  <div>
      Severity: Minor
      Found in scripts/apps/workspace/content/components/new-field-select.tsx - About 1 hr to fix

        Function handleCheckingVideo has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            handleCheckingVideo(resetState: boolean = true, callback?: () => void) {
                this.intervalCheckVideo = window.setInterval(() => {
                    this.props.superdesk.dataApi
                        .findOne<IVideoProject>('video_edit', this.state.article._id)
                        .then((result) => {
        Severity: Minor
        Found in scripts/extensions/videoEditor/src/VideoEditor.tsx - About 1 hr to fix

          Function queryMimetypes has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function queryMimetypes(source: IRootElasticQuery, params: IAssetSearchParams) {
              if (params.mimetypes === ASSET_TYPE_FILTER.DOCUMENTS) {
                  source.query.bool.must_not.push(
                      superdeskApi.elasticsearch.queryString({
                          query: 'mimetype:(image\\/*) OR mimetype:(video\\/*) OR mimetype:(audio\\/*)',
          Severity: Minor
          Found in scripts/extensions/sams/src/api/assets.ts - About 1 hr to fix

            Function getFieldV2 has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getFieldV2: (fieldEditor, fieldSchema) => {
                    const vocabulary = sdApi.vocabularies.getAll().get('priority');
            
                    // HAS TO BE SYNCED WITH styles/sass/labels.scss
                    var defaultPriorityColors = {
            Severity: Minor
            Found in scripts/apps/authoring-react/field-adapters/priority.ts - About 1 hr to fix

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

                  render() {
                      const {config} = this.props;
                      const Container = this.props.container;
                      const values = this.props.value;
              
              

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

                    render(): React.ReactNode {
                        return (
                            <Button
                                icon="settings"
                                shape="round"
                Severity: Minor
                Found in scripts/apps/authoring-react/authoring-swtich.tsx - About 1 hr to fix

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

                      render() {
                          const lockedInOtherSession = isLockedInOtherSession(this.props.entity);
                  
                          if (lockedInOtherSession !== true) {
                              return null;
                  Severity: Minor
                  Found in scripts/apps/authoring-react/subcomponents/lock-info-generic.tsx - About 1 hr to fix

                    Function arrangeLabels has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                                    function arrangeLabels() {
                                        var move = 1;
                    
                                        while (move > 0) {
                                            move = 0;
                    Severity: Minor
                    Found in scripts/apps/ingest/directives/PieChartDashboard.ts - About 1 hr to fix

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

                          render() {
                              const {scope, svc} = this.props;
                      
                              const _createItem = function createItem(itemId) {
                                  const item = this.state.itemsById[itemId];
                      Severity: Minor
                      Found in scripts/apps/contacts/components/ItemList.tsx - About 1 hr to fix

                        Function upload has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            $scope.upload = function(config) {
                                var form: any = {};
                        
                                form.CropLeft = Math.round(Math.min(config.cords.x, config.cords.x2));
                                form.CropRight = Math.round(Math.max(config.cords.x, config.cords.x2));
                        Severity: Minor
                        Found in scripts/apps/users/controllers/ChangeAvatarController.ts - About 1 hr to fix

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

                              render() {
                                  const {item, showAltText, className} = this.props;
                                  const validator = appConfig.validator_media_metadata;
                                  const NO_VALUE_LABEL = gettext('[No Value]');
                          
                          
                          Severity: Minor
                          Found in scripts/apps/authoring/media/MediaMetadataView.tsx - About 1 hr to fix

                            Function save has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                        $scope.save = function() {
                                            return authoring.save(
                                                $scope.origItem,
                                                $scope.item,
                                                $scope.requestEditor3DirectivesToGenerateHtml,
                            Severity: Minor
                            Found in scripts/apps/authoring/authoring/directives/AuthoringDirective.ts - About 1 hr to fix

                              Function dataSource has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                          dataSource(fetchFn) {
                                              const markedQuery = extensions['markForUser']
                                                  ?.extension
                                                  .exposes
                                                  .getQueryNotMarkedForAnyoneOrMarkedForMe(userId);

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

                                        link: function(scope) {
                                            scope.transmitted_item = null;
                                            scope.show_transmission_details = false;
                                
                                            /**

                                  Function MediaPreview has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export const MediaPreview: React.StatelessComponent<IProps> = (props) => {
                                      const {item, multiSelect} = props;
                                      const headline = item.headline || item.slugline || item.type;
                                      // headline could contains html tags hence stripping for tooltips
                                      const headlineText = headline.replace(/(<([^>]+)>)/ig, '');
                                  Severity: Minor
                                  Found in scripts/apps/search/components/MediaPreview.tsx - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language