udondan/iam-floyd

View on GitHub

Showing 37 of 99 total issues

Function main has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function main() {
  const changelog = getChangelog();

  const toots: string[] = [];
  const split = changelog
Severity: Minor
Found in bin/toot.ts - About 1 hr to fix

    Function cdkApplyPrincipals has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      protected cdkApplyPrincipals() {
        if (!this.cdkPrincipalsApplied) {
          const mode = this.useNotPrincipal ? 'addNotPrincipals' : 'addPrincipals';
          // @ts-ignore only available after swapping 1-base
          this[mode](...this.cdkPrincipals);
    Severity: Minor
    Found in lib/shared/policy-statement/9-principals-CDK.ts - About 1 hr to fix

      Function requestWithRetry has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function requestWithRetry(
        url: string,
        options: request.CoreOptions = {},
        retries = 3,
        backoff = 300,
      Severity: Minor
      Found in lib/generator/index.ts - About 1 hr to fix

        Function getAwsServicesFromIamDocs has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getAwsServicesFromIamDocs(): Promise<string[]> {
          return new Promise((resolve, reject) => {
            const url =
              'https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_actions-resources-contextkeys.html';
            requestWithRetry(url)
        Severity: Minor
        Found in lib/generator/index.ts - About 1 hr to fix

          Function add has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public add(name: string, value: string, description: string) {
              this.filesNames.forEach((fileName: string) => {
                if (fileName === 'cdk-iam-floyd') {
                  this.files[fileName].collection
                    .addMethod({
          Severity: Minor
          Found in lib/generator/managed-policies.ts - About 1 hr to fix

            Function createIndex has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function createIndex() {
              const filePath = './lib/generated/index.ts';
              process.stdout.write('index: '.white);
              process.stdout.write('Generating '.cyan);
            
            
            Severity: Minor
            Found in lib/generator/index.ts - About 1 hr to fix

              Function indexManagedPolicies has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function indexManagedPolicies(): Promise<void> {
                console.log('starting');
                const managedPolicies = new ManagedPolicies();
                const policyNames: string[] = [];
                const policies = await getPolicies();
              Severity: Minor
              Found in lib/generator/managed-policies.ts - About 1 hr to fix

                Function run has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function run() {
                  const args = process.argv.slice(2);
                
                  const doFileSwap = !args.length || args.includes('--swap');
                  const doPackageJson = !args.length || args.includes('--package-json');
                Severity: Minor
                Found in bin/mkcdk.ts - About 1 hr to fix

                  Function conditionFixer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function conditionFixer(
                    service: string,
                    condition: Condition,
                  ): Condition {
                    let fixed = 0;
                  Severity: Minor
                  Found in lib/generator/fixes.ts - 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 makeStatementCode has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    language,
                    effect,
                    service,
                    actions,
                    resources,
                  Severity: Major
                  Found in docs/source/_static/js/policy-converter.js - About 1 hr to fix

                    Function splitActionsByService has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function splitActionsByService(actions) {
                      const serviceActions = {};
                      for (let action of actions) {
                        const split = action.split(':');
                        if (split.length == 1 && action != '*') {
                    Severity: Minor
                    Found in docs/source/_static/js/policy-converter.js - About 55 mins 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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    async function run() {
                      const args = process.argv.slice(2);
                    
                      const doFileSwap = !args.length || args.includes('--swap');
                      const doPackageJson = !args.length || args.includes('--package-json');
                    Severity: Minor
                    Found in bin/mkcdk.ts - About 35 mins 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 fixPolicyStatement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function fixPolicyStatement(project: Project) {
                      // loop over files in ../lib/shared/policy-statement:
                      for (const fileName of fs.readdirSync(`${lib}/shared/policy-statement`)) {
                        if (fileName.endsWith('.ts') && !fileName.endsWith('.d.ts')) {
                          const file = path.join(
                    Severity: Minor
                    Found in bin/mkcdk.ts - About 35 mins 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 toJSON has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public toJSON(): any {
                        // @ts-ignore only available after swapping 1-base
                        if (typeof this.addResources == 'function') {
                          this.cdkApplyActions();
                          return super.toJSON();
                    Severity: Minor
                    Found in lib/shared/policy-statement/3-actions.ts - About 35 mins 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 if has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public if(key: string, value: any, operator?: Operator | string) {
                        if (this.servicePrefix.length && key.indexOf(':') < 0) {
                          key = `${this.servicePrefix}:${key}`;
                        }
                    
                    
                    Severity: Minor
                    Found in lib/shared/policy-statement/2-conditions.ts - About 35 mins 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 makeMethodCall has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function makeMethodCall(method, params = []) {
                      let code = '.' + method + '(';
                      if (params.length) {
                        const paramList = [];
                        for (let param of params) {
                    Severity: Minor
                    Found in docs/source/_static/js/policy-converter.js - About 35 mins 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 toString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public toString() {
                        let value = this.base;
                    
                        if (this.base.length == 0) {
                          throw new Error('No operator set');
                    Severity: Minor
                    Found in lib/shared/operators.ts - About 25 mins 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

                    Severity
                    Category
                    Status
                    Source
                    Language