18F/federalist

View on GitHub

Showing 83 of 394 total issues

Function JSONTreeView has a Cognitive Complexity of 307 (exceeds 5 allowed). Consider refactoring.
Open

function JSONTreeView(name_, value_, parent_, isRoot_) {
  const self = this;
  this.ee = new EventEmitter();
  this.on = (...args) => this.ee.on(...args);
  this.once = (...args) => this.ee.once(...args);
Severity: Minor
Found in admin-client/src/lib/jsonTreeView.js - About 6 days 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 JSONTreeView has 726 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function JSONTreeView(name_, value_, parent_, isRoot_) {
  const self = this;
  this.ee = new EventEmitter();
  this.on = (...args) => this.ee.on(...args);
  this.once = (...args) => this.ee.once(...args);
Severity: Major
Found in admin-client/src/lib/jsonTreeView.js - About 3 days to fix

    Function createData has 391 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function createData() {
      console.log('Cleaning database...');
      await cleanDatabase();
    
      /** *****************************************
    Severity: Major
    Found in scripts/create-dev-data.js - About 1 day to fix

      File jsonTreeView.js has 762 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * https://gist.github.com/mudge/5830382#gistcomment-2691957
       */
      class EventEmitter {
        constructor() {
      Severity: Major
      Found in admin-client/src/lib/jsonTreeView.js - About 1 day to fix

        File create-dev-data.js has 474 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-disable no-console */
        const { addDays } = require('date-fns');
        Promise.props = require('promise-props');
        const BuildLogs = require('../api/services/build-logs');
        const { encrypt } = require('../api/services/Encryptor');
        Severity: Minor
        Found in scripts/create-dev-data.js - About 7 hrs to fix

          Function SiteBuilds has 137 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function SiteBuilds() {
            const { id } = useParams();
            const [autoRefresh, setAutoRefresh] = useState(false);
            const site = useSelector(state => currentSite(state.sites, id));
            const organization = useSelector(state => getOrgById(state.organizations, site.organizationId));
          Severity: Major
          Found in frontend/components/site/siteBuilds.jsx - About 5 hrs to fix

            Function exports has 125 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = (sequelize, DataTypes) => {
              const Site = sequelize.define('Site', {
                demoBranch: {
                  type: DataTypes.STRING,
                  validate: {
            Severity: Major
            Found in api/models/site.js - About 5 hrs to fix

              Function exports has 86 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = (sequelize, DataTypes) => {
                const Build = sequelize.define(
                  'Build',
                  {
                    branch: {
              Severity: Major
              Found in api/models/build.js - About 3 hrs to fix

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

                export function SiteContainer(props) {
                  const { id } = useParams();
                  const location = useLocation();
                  const params = useSearchParams();
                  const sites = useSelector(state => state.sites);
                Severity: Major
                Found in frontend/components/siteContainer.jsx - About 3 hrs to fix

                  CloudFoundryAPIClient has 27 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class CloudFoundryAPIClient {
                    constructor({ apiUrl, authClient } = {}) {
                      this.authClient = authClient ?? new CloudFoundryAuthClient();
                      this.httpClient = new HttpClient(apiUrl ?? process.env.CLOUD_FOUNDRY_API_HOST);
                    }
                  Severity: Minor
                  Found in apps/metrics/lib/cfApiClient.js - About 3 hrs to fix

                    Function AddSite has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function AddSite() {
                      useEffect(() => () => {
                        // dispatch the action to hide the additional new site fields
                        // when this component is unmounted
                        addNewSiteFieldsActions.hideAddNewSiteFields();
                    Severity: Major
                    Found in frontend/components/AddSite/index.jsx - About 3 hrs to fix

                      Function define has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function define(sequelize, DataTypes) {
                        const SiteBranchConfig = sequelize.define(
                          'SiteBranchConfig',
                          {
                            branch: {
                      Severity: Major
                      Found in api/models/site-branch-config.js - About 3 hrs to fix

                        File build.js has 279 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        const { Op } = require('sequelize');
                        const crypto = require('crypto');
                        const URLSafeBase64 = require('urlsafe-base64');
                        const SiteBuildQueue = require('../services/SiteBuildQueue');
                        
                        
                        Severity: Minor
                        Found in api/models/build.js - About 2 hrs to fix

                          Function define has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function define(sequelize, DataTypes) {
                            const Domain = sequelize.define('Domain', {
                              names: {
                                type: DataTypes.STRING,
                                allowNull: false,
                          Severity: Major
                          Found in api/models/domain.js - About 2 hrs to fix

                            Function create has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              async create(req, res) {
                                const { body, params, user } = req;
                                const { site_id: siteId } = params;
                            
                                const site = await Site.forUser(user).findByPk(siteId);
                            Severity: Major
                            Found in api/controllers/site-branch-config.js - About 2 hrs to fix

                              Function update has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                async update(req, res) {
                                  const { body, params, user } = req;
                                  const { site_id: siteId, id } = params;
                              
                                  const site = await Site.forUser(user).findByPk(siteId);
                              Severity: Major
                              Found in api/controllers/site-branch-config.js - About 2 hrs to fix

                                File federalistApi.js has 270 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import fetch from './fetch';
                                import alertActions from '../actions/alertActions';
                                
                                export const API = '/v0';
                                
                                
                                Severity: Minor
                                Found in frontend/util/federalistApi.js - About 2 hrs to fix

                                  Function SiteSettings has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function SiteSettings() {
                                    const { id } = useParams();
                                    const site = useSelector(state => currentSite(state.sites, id));
                                    const navigate = useNavigate();
                                  
                                  
                                  Severity: Major
                                  Found in frontend/components/site/SiteSettings/index.jsx - About 2 hrs to fix

                                    File cfApiClient.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
                                    Open

                                    const CloudFoundryAuthClient = require('./cfAuthClient');
                                    const HttpClient = require('./httpClient');
                                    
                                    function filterEntity(res, name, field = 'name') {
                                      const errMsg = `Not found: Entity @${field} = ${name}`;
                                    Severity: Minor
                                    Found in apps/metrics/lib/cfApiClient.js - About 2 hrs to fix

                                      File api.js has 261 lines of code (exceeds 250 allowed). Consider refactoring.
                                      Open

                                      /* eslint-disable no-console */
                                      /* global API_URL */
                                      import { notification, session } from '../stores';
                                      import { logout as authLogout } from './auth';
                                      
                                      
                                      Severity: Minor
                                      Found in admin-client/src/lib/api.js - About 2 hrs to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language