OpenSCAP/foreman_openscap

View on GitHub

Showing 76 of 163 total issues

Function EditableInput has 113 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const EditableInput = props => {
  const [editing, setEditing] = useState(false);
  const [submitting, setSubmitting] = useState(false);
  const [inputValue, setInputValue] = useState(props.value);
  const [error, setError] = useState('');
Severity: Major
Found in webpack/components/EditableInput.js - About 4 hrs to fix

    Function OvalContentsNew has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const OvalContentsNew = props => {
      const [file, setFile] = useState(null);
      const [fileTouched, setFileTouched] = useState(false);
      const [fileFromUrl, setFileFromUrl] = useState(true);
    
    
    Severity: Major
    Found in webpack/routes/OvalContents/OvalContentsNew/OvalContentsNew.js - About 3 hrs to fix

      Function HostgroupSelect has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      const HostgroupSelect = ({
        selected,
        setSelected,
        hgsError,
        showError,
      Severity: Minor
      Found in webpack/routes/OvalPolicies/OvalPoliciesNew/HostgroupSelect.js - 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 withLoading has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const withLoading = Component => {
        const Subcomponent = ({
          fetchFn,
          resultPath,
          renameData,
      Severity: Major
      Found in webpack/components/withLoading.js - About 2 hrs to fix

        File engine.rb has 275 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module ForemanOpenscap
          def self.with_katello?
            Foreman::Plugin.installed?("katello")
          end
        
        
        Severity: Minor
        Found in lib/foreman_openscap/engine.rb - About 2 hrs to fix

          Method create_arf has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.create_arf(asset, proxy, params)
                arf_report = nil
                policy = Policy.find_by :id => params[:policy_id]
                return unless policy
          
          
          Severity: Minor
          Found in app/models/foreman_openscap/arf_report.rb - About 2 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 ArfReport has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class ArfReport < ::Report
              include Taxonomix
              include OpenscapProxyExtensions
          
              # attr_accessible :host_id, :reported_at, :status, :metrics
          Severity: Minor
          Found in app/models/foreman_openscap/arf_report.rb - About 2 hrs to fix

            Method prepended has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def self.prepended(base)
                  base.has_one :asset, :as => :assetable, :class_name => "::ForemanOpenscap::Asset", :dependent => :destroy
                  base.has_many :asset_policies, :through => :asset, :class_name => "::ForemanOpenscap::AssetPolicy"
                  base.has_many :policies, :through => :asset_policies, :class_name => "::ForemanOpenscap::Policy"
                  base.has_many :arf_reports, :class_name => '::ForemanOpenscap::ArfReport', :foreign_key => :host_id
            Severity: Major
            Found in app/models/concerns/foreman_openscap/host_extensions.rb - About 2 hrs to fix

              Function DetailsTab has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const DetailsTab = props => {
                const { policy, showToast } = props;
              
                const [callMutation] = useMutation(updateOvalPolicyMutation);
              
              
              Severity: Major
              Found in webpack/routes/OvalPolicies/OvalPoliciesShow/DetailsTab.js - About 2 hrs to fix

                Function onSubmit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                export const onSubmit = (
                  history,
                  showToast,
                  callMutation,
                  assignedHgs,

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

                const OvalContentsTable = props => {
                  const columns = [
                    { title: __('Name') },
                    { title: __('URL') },
                    { title: __('Original File Name') },
                Severity: Major
                Found in webpack/routes/OvalContents/OvalContentsIndex/OvalContentsTable.js - About 2 hrs to fix

                  Function onSubmit has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  ) => (values, actions) => {
                    const onCompleted = response => {
                      const failedChecks = response.data.createOvalPolicy.checkCollection.filter(
                        check => check.result === 'fail'
                      );

                    Method process_policy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def process_policy(policy)
                          reports_of_policy = ForemanOpenscap::ArfReport.unscoped
                                                                        .of_policy(policy)
                                                                        .order("#{ForemanOpenscap::ArfReport.table_name}.created_at DESC")
                          latest = reports_of_policy.first
                    Severity: Minor
                    Found in lib/foreman_openscap/message_cleaner.rb - About 1 hr 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 upload_from_files has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def upload_from_files(files_array, from_scap_guide = false)
                          unless files_array.is_a? Array
                            @result.errors.push(_("Expected an array of files to upload, got: %s.") % files_array)
                            return @result
                          end
                    Severity: Minor
                    Found in lib/foreman_openscap/bulk_upload.rb - About 1 hr 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 create_arf has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.create_arf(asset, proxy, params)
                          arf_report = nil
                          policy = Policy.find_by :id => params[:policy_id]
                          return unless policy
                    
                    
                    Severity: Minor
                    Found in app/models/foreman_openscap/arf_report.rb - About 1 hr to fix

                      Function OvalPoliciesShow has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      const OvalPoliciesShow = props => {
                        const { policy, match, history } = props;
                        const activeTab = match.params.tab ? match.params.tab : 'details';
                      
                        const handleTabSelect = (event, value) => {
                      Severity: Minor
                      Found in webpack/routes/OvalPolicies/OvalPoliciesShow/OvalPoliciesShow.js - About 1 hr to fix

                        Method find_multiple has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def find_multiple
                            if params.key?(:host_names) || params.key?(:host_ids) || multiple_with_filter?
                              @hosts = Host.search_for(params[:search]) if multiple_with_filter?
                              @hosts ||= Host.merge(Host.where(id: params[:host_ids]).or(Host.where(name: params[:host_names])))
                              if @hosts.empty?
                        Severity: Minor
                        Found in app/controllers/policies_controller.rb - About 1 hr 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 OvalPoliciesTable has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const OvalPoliciesTable = props => {
                          const columns = [{ title: __('Name') }, { title: __('OVAL Content') }];
                        
                          const rows = props.policies.map(policy => ({
                            cells: [
                        Severity: Minor
                        Found in webpack/routes/OvalPolicies/OvalPoliciesIndex/OvalPoliciesTable.js - About 1 hr to fix

                          Function OvalContentsIndex has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const OvalContentsIndex = props => {
                            const useFetchFn = componentProps =>
                              useQuery(ovalContentsQuery, {
                                variables: useParamsToVars(componentProps.history),
                              });
                          Severity: Minor
                          Found in webpack/routes/OvalContents/OvalContentsIndex/OvalContentsIndex.js - About 1 hr to fix

                            Function deleteMockFactory has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const deleteMockFactory = (first, second, errors = null) => {
                              let called = false;
                            
                              const deleteMocks = [
                                {
                              Severity
                              Category
                              Status
                              Source
                              Language