concord-consortium/lara

View on GitHub

Showing 830 of 830 total issues

File mock-api-provider.ts has 605 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { findItemAddress, findItemByAddress } from "../util/finding-utils";
import { setSectionPositions, updatePositions } from "../util/move-utils";
import {
  IPage, PageId,
  APIPageGetF, APIPagesGetF, APIPageItemUpdateF,
Severity: Major
Found in lara-typescript/src/section-authoring/api/mock-api-provider.ts - About 1 day to fix

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

    export const AppComponent: React.FC<Props> = (props) => {
      const initMessage = useInitMessage<{}, IAuthoredState>();
    
      useAutoSetHeight();
    
    
    lara-typescript/src/example-interactives/src/testbed/app.tsx on lines 13..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 228.

    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

    export const AppComponent: React.FC<Props> = (props) => {
      const initMessage = useInitMessage<{}, IAuthoredState>();
    
      useAutoSetHeight();
    
    
    Severity: Major
    Found in lara-typescript/src/example-interactives/src/testbed/app.tsx and 1 other location - About 1 day to fix
    lara-typescript/src/example-interactives/src/linked-state/app.tsx on lines 13..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 228.

    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

                            if (settings.maxw && photo.width > settings.maxw) {
                                // Reduce to the max width || max height
                                percent = (photo.width - settings.maxw) / photo.width;
                                if (photo.height - (photo.height * percent) > settings.maxh) {
                                    // Still too big, do it by height
    Severity: Major
    Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 1 day to fix
    app/assets/javascripts/jquery.colorbox.js on lines 1032..1058

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

    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

                            if (settings.maxh && photo.height > settings.maxh) {
                                // Reduce to the max width || max height
                                percent = (photo.height - settings.maxh) / photo.height;
                                if (photo.width - (photo.width * percent) > settings.maxw) {
                                    // Still too wide, use maxw
    Severity: Major
    Found in app/assets/javascripts/jquery.colorbox.js and 1 other location - About 1 day to fix
    app/assets/javascripts/jquery.colorbox.js on lines 1004..1030

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

    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

    File api.spec.ts has 553 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { mockIFramePhone, MockPhone } from "../interactive-api-lara-host/mock-iframe-phone";
    import * as iframePhone from "iframe-phone";
    import * as api from "./api";
    import { getClient } from "./client";
    import {
    Severity: Major
    Found in lara-typescript/src/interactive-api-client/api.spec.ts - About 1 day to fix

      File iframe-saver.ts has 533 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { ParentEndpoint } from "iframe-phone";
      import * as DOMPurify from "dompurify";
      import { IframePhoneManager } from "./iframe-phone-manager";
      import { IFrameSaverPluginApi } from "./iframe-saver-plugin";
      import { ModalApiPlugin } from "./modal-api-plugin";
      Severity: Major
      Found in lara-typescript/src/interactive-api-lara-host/iframe-saver.ts - About 1 day to fix

        Function ShutterbugWorker has 218 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                var ShutterbugWorker = function () {
                  function ShutterbugWorker(options) {
                    _classCallCheck(this, ShutterbugWorker);
        
                    var opt = options || {};
        Severity: Major
        Found in app/assets/javascripts/shutterbug.js - About 1 day to fix

          Function usePageAPI has 211 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const usePageAPI = () => {
          
            const { userInterface, actions } = useContext(UserInterfaceContext);
            const provider: IAuthoringAPIProvider = useContext(APIContext);
            const client = useQueryClient(); // Get the context from our container.
          Severity: Major
          Found in lara-typescript/src/section-authoring/hooks/use-api-provider.ts - About 1 day to fix

            Function CustomizeMWInteractive has 197 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const CustomizeMWInteractive: React.FC<Props> = (props) => {
              const {
                checkboxHandler,
                defaultClickToPlayPrompt,
                enableLearnerStateRef,
            Severity: Major
            Found in lara-typescript/src/page-item-authoring/mw-interactives/customize.tsx - About 7 hrs to fix

              Function usePageAPI has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
              Open

              export const usePageAPI = () => {
              
                const { userInterface, actions } = useContext(UserInterfaceContext);
                const provider: IAuthoringAPIProvider = useContext(APIContext);
                const client = useQueryClient(); // Get the context from our container.
              Severity: Minor
              Found in lara-typescript/src/section-authoring/hooks/use-api-provider.ts - About 7 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 SectionItemPicker has 189 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export const SectionItemPicker: React.FC<IProps> = (props) => {
                const api = usePageAPI();
                const allItems = useMemo(() => {
                  if (!api.getAllEmbeddables.data) {
                    return undefined;

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

                  function post(type, content) {
                    var message;
                    // Message object can be constructed from 'type' and 'content' arguments or it can be passed
                    // as the first argument.
                    if (arguments.length === 1 && typeof type === 'object' && typeof type.type === 'string') {
                Severity: Major
                Found in public/demo-interactives/iframe-phone.js and 1 other location - About 7 hrs to fix
                app/assets/javascripts/iframe-phone.js on lines 289..316

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

                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 post(type, content) {
                      var message;
                      // Message object can be constructed from 'type' and 'content' arguments or it can be passed
                      // as the first argument.
                      if (arguments.length === 1 && typeof type === 'object' && typeof type.type === 'string') {
                Severity: Major
                Found in app/assets/javascripts/iframe-phone.js and 1 other location - About 7 hrs to fix
                public/demo-interactives/iframe-phone.js on lines 277..304

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

                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

                },{"./structured-clone":4}],4:[function(require,module,exports){
                var featureSupported = {
                  'structuredClones': 0
                };
                
                
                Severity: Major
                Found in public/demo-interactives/iframe-phone.js and 1 other location - About 7 hrs to fix
                app/assets/javascripts/iframe-phone.js on lines 435..463

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

                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

                  },{"./structured-clone":4}],4:[function(require,module,exports){
                  var featureSupported = {
                    'structuredClones': 0
                  };
                
                
                Severity: Major
                Found in app/assets/javascripts/iframe-phone.js and 1 other location - About 7 hrs to fix
                public/demo-interactives/iframe-phone.js on lines 417..445

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

                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

                File types.ts has 448 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import { IEventListeners } from "../plugin-api";
                
                // Export some shared types.
                export { IPortalClaims, IJwtClaims, IJwtResponse } from "../shared/types";
                
                
                Severity: Minor
                Found in lara-typescript/src/interactive-api-shared/types.ts - About 6 hrs to fix

                  Method set_linked_interactives has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def set_linked_interactives(options)
                      source_page_item_id = id
                  
                      ActiveRecord::Base.transaction do
                        if options.has_key?("linkedInteractives")
                  Severity: Minor
                  Found in app/models/page_item.rb - About 6 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

                  File interactive_pages_controller.rb has 446 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  class Api::V1::InteractivePagesController < API::APIController
                    layout false
                    before_filter :set_interactive_page, except: [
                      :get_library_interactives_list,
                      :get_wrapping_plugins_list,
                  Severity: Minor
                  Found in app/controllers/api/v1/interactive_pages_controller.rb - About 6 hrs to fix

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

                    export const Copy = (props: ICopyProps) => {
                      const height = props.height ? props.height : kDefaultHeight;
                      const width = props.width ? props.width : kDefaultWidth;
                    
                      return(
                    Severity: Major
                    Found in lara-typescript/src/shared/components/icons/copy-icon.tsx and 1 other location - About 6 hrs to fix
                    lara-typescript/src/shared/components/icons/add-icon.tsx on lines 11..32

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

                    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