Katello/katello

View on GitHub

Showing 2,737 of 2,737 total issues

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

  it('creates TABLES_REQUEST with failure', async () => {
    mockRequest({
      url: '/api/v2/users/1/table_preferences',
      status: 403,
      response: accessDenied,
webpack/scenes/Settings/Tables/__tests__/TableActions.test.js on lines 35..43

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

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

                  <Td
                    aria-label={`expand-env-${id}`}
                    style={{ paddingTop: 0 }}
                    expand={{
                      rowIndex,
Severity: Major
Found in webpack/scenes/SmartProxy/SmartProxyExpandableTable.js and 1 other location - About 1 hr to fix
webpack/scenes/SmartProxy/ExpandableCvDetails.js on lines 50..59

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

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

              <Td
                aria-label={`expand-cv-${id}`}
                style={{ paddingTop: 0 }}
                expand={{
                  rowIndex,
Severity: Major
Found in webpack/scenes/SmartProxy/ExpandableCvDetails.js and 1 other location - About 1 hr to fix
webpack/scenes/SmartProxy/SmartProxyExpandableTable.js on lines 97..106

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

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

          {environments?.map(({ name, id: envId }) => (
            <FlexItem key={name}>
              <Label isTruncated color="purple" href={`/lifecycle_environments/${envId}`}>{name}</Label>
            </FlexItem>))}
webpack/scenes/ContentViews/Details/Versions/BulkDelete/Steps/ConfirmBulkDelete.js on lines 78..81

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

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

function withOrganization(WrappedComponent) {
  class CheckOrg extends Component {
    constructor(props) {
      super(props);
      this.state = { orgId: null };
Severity: Minor
Found in webpack/components/WithOrganization/withOrganization.js - About 1 hr to fix

    Function ACSSmartProxies has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const ACSSmartProxies = () => {
      const {
        smartProxies, setSmartProxies, useHttpProxies, setUseHttpProxies,
      } = useContext(ACSCreateContext);
      const availableSmartProxies = useSelector(selectSmartProxy);

      Function CVDebFilterContent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      const CVDebFilterContent = ({
        cvId, filterId, inclusion, showAffectedRepos, setShowAffectedRepos, details,
      }) => {
        const response = useSelector(state => selectCVFilterRules(state, filterId), shallowEqual);
        const { results, ...metadata } = response;
      Severity: Minor
      Found in webpack/scenes/ContentViews/Details/Filters/CVDebFilterContent.js - 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 ContentViewVersionPromote has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      const ContentViewVersionPromote = ({
        cvId, versionIdToPromote, versionNameToPromote,
        versionEnvironments, setIsOpen, detailsPage,
      }) => {
        const [description, setDescription] = useState('');

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

      const ContentViewRepositories = ({ cvId, details }) => {
        const dispatch = useDispatch();
        const response = useSelector(state => selectCVRepos(state, cvId), shallowEqual);
        const { results, ...metadata } = response;
        const { org_repository_count: orgRepositoryCount } = metadata;

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

      const CVRpmFilterContent = ({
        cvId, filterId, inclusion, showAffectedRepos, setShowAffectedRepos, details,
      }) => {
        const response = useSelector(state => selectCVFilterRules(state, filterId), shallowEqual);
        const { results, ...metadata } = response;
      Severity: Minor
      Found in webpack/scenes/ContentViews/Details/Filters/CVRpmFilterContent.js - 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 check_blob_push_org_label has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_blob_push_org_label(props)
            org_label = props[:organization]
            unless org_label.present? && org_label.length > 0
              return render_podman_error(
                "NAME_INVALID",
      Severity: Minor
      Found in app/controllers/katello/api/registry/registry_proxies_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

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

          def authorize_repository_read
            @repository = find_readable_repository
            return item_not_found(params[:repository]) unless @repository
      
            if params[:tag]
      Severity: Minor
      Found in app/controllers/katello/api/registry/registry_proxies_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

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

          def sort(field, options = {}, html_options = {})
            unless options[:as]
              id           = field.to_s.downcase == "id"
              options[:as] = id ? field.to_s.upcase : field.to_s.humanize
            end
      Severity: Minor
      Found in app/helpers/katello/application_helper.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 validate_ssl_ids has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_ssl_ids
            # Simplified ACS's should never have ssl-* params populated
            if simplified?
              if changes.keys.include? "ssl_ca_cert_id"
                errors.add(:ssl_ca_cert, "cannot be set for simplified ACS")
      Severity: Minor
      Found in app/models/katello/alternate_content_source.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 params_to_rhsm_params has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def params_to_rhsm_params
            rhsm_params = params.slice(:facts, :uuid, :name).to_unsafe_h
            rhsm_params[:releaseVer] = params['release_version'] if params['release_version']
            rhsm_params[:usage] = params['purpose_usage'] if params['purpose_usage']
            rhsm_params[:role] = params['purpose_role'] if params['purpose_role']
      Severity: Minor
      Found in app/controllers/katello/api/v2/host_subscriptions_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

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

              def plan(repo, options = {})
                action_subject(repo)
                repo.check_ready_to_act!
      
                validate_contents = options.fetch(:validate_contents, false)
      Severity: Minor
      Found in app/lib/actions/katello/repository/sync.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 generic_remote_options has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def generic_remote_options(opts = {})
              options = []
              sorted_options = {}
              repo_types = opts[:defined_only] ? defined_repository_types : enabled_repository_types
              repo_types.each do |_, type|
      Severity: Minor
      Found in app/services/katello/repository_type_manager.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 results has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def results
              if operator == EQUAL
                conditions = epoch_clause(operator)
                conditions += ' AND ' + version_clause(operator) unless version.blank?
                conditions += ' AND ' + release_clause(operator) unless release.blank?
      Severity: Minor
      Found in app/lib/katello/util/package_filter.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 save_smart_proxy_sync_history has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def save_smart_proxy_sync_history
              if (action.input[:repository_id] && (action.input[:smart_proxy_id] || action.input[:capsule_id]) && !self.action.output[:smart_proxy_history_id])
                repo_id = action.input[:repository_id]
                repo = ::Katello::Repository.find_by(id: repo_id)
                smart_proxy_id = action.input[:smart_proxy_id] || action.input[:capsule_id]
      Severity: Minor
      Found in app/lib/actions/middleware/record_smart_proxy_sync_history.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

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

                  <TextListItem>
                    {__('The Foreman Client repository is available in the host\'s content view environment(s). ')}
                    <a onClick={() => setButtonLoading(true)} href="/content_views" id="enable-tracer-cv-link">
                      {__('View content views')}
                    </a>
      webpack/components/extensions/HostDetails/Tabs/TracesTab/EnableTracerModal.js on lines 66..72
      webpack/components/extensions/HostDetails/Tabs/TracesTab/EnableTracerModal.js on lines 73..79

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

      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