fair-search/fairsearch-elasticsearch-plugin

View on GitHub

Showing 27 of 42 total issues

Method adjustAlpha has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    public MTableFailProbPair adjustAlpha() {
        double aMin = 0;
        double aMax = alpha;
        double aMid = (aMin + aMax) / 2;

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

    public TopDocs fairTopK(List<ScoreDoc> npQueue, List<ScoreDoc> pQueue, int k, float p, float alpha) {

        FairScorer scorer = new FairScorer(k);

        int [] m = fairnessLookup.fairnessAsTable(k, p, alpha);
Severity: Major
Found in src/main/java/com/purbon/search/fair/lib/FairTopKImpl.java - About 3 hrs to fix

    Method rescore has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

            @Override
            public TopDocs rescore(TopDocs topDocs, IndexSearcher searcher, RescoreContext rescoreContext) throws IOException {
    
                FairRescoreContext context = (FairRescoreContext)rescoreContext;
                FairSearchConfig config = context.getConfig();
    Severity: Minor
    Found in src/main/java/com/purbon/search/fair/query/FairRescoreBuilder.java - 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

    Method fairTopK has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public TopDocs fairTopK(List<ScoreDoc> npQueue, List<ScoreDoc> pQueue, int k, float p, float alpha) {
    
            FairScorer scorer = new FairScorer(k);
    
            int [] m = fairnessLookup.fairnessAsTable(k, p, alpha);
    Severity: Minor
    Found in src/main/java/com/purbon/search/fair/lib/FairTopKImpl.java - 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

    File FairRescoreBuilder.java has 269 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package com.purbon.search.fair.query;
    
    import com.purbon.search.fair.ModelStore;
    import com.purbon.search.fair.lib.FairTopK;
    import com.purbon.search.fair.lib.FairTopKImpl;
    Severity: Minor
    Found in src/main/java/com/purbon/search/fair/query/FairRescoreBuilder.java - About 2 hrs to fix

      FairSearchConfig has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      public class FairSearchConfig {
      
      
          private static Logger logger = ESLoggerFactory.getLogger(FairSearchConfig.class);
      
      
      Severity: Minor
      Found in src/main/java/com/purbon/search/fair/query/FairSearchConfig.java - About 2 hrs to fix

        Method rescore has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                @Override
                public TopDocs rescore(TopDocs topDocs, IndexSearcher searcher, RescoreContext rescoreContext) throws IOException {
        
                    FairRescoreContext context = (FairRescoreContext)rescoreContext;
                    FairSearchConfig config = context.getConfig();
        Severity: Major
        Found in src/main/java/com/purbon/search/fair/query/FairRescoreBuilder.java - About 2 hrs to fix

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

              public void resolveNullEntries() {
                  if (col1.size() == 0 && col2.size() == 0){
                      return;
                  }
                  col1.set(0, 0);
          Severity: Minor
          Found in src/main/java/com/purbon/search/fair/utils/DataFrame.java - 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 adjustAlpha has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public MTableFailProbPair adjustAlpha() {
                  double aMin = 0;
                  double aMax = alpha;
                  double aMid = (aMin + aMax) / 2;
          
          

            Method computeFailureProbability has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public double computeFailureProbability() {
                    if (mTable[mTable.length - 1] == 0) {
                        return 0;
                    }
                    DataFrame auxMTable = this.mTableGenerator.computeAuxTMTable();
            Severity: Minor
            Found in src/main/java/com/purbon/search/fair/utils/AlphaAdjuster.java - About 1 hr to fix

              Method computeFailureProbability has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  public double computeFailureProbability() {
                      if (mTable[mTable.length - 1] == 0) {
                          return 0;
                      }
                      DataFrame auxMTable = this.mTableGenerator.computeAuxTMTable();
              Severity: Minor
              Found in src/main/java/com/purbon/search/fair/utils/AlphaAdjuster.java - 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 createMtableAndExecuteQuery has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function createMtableAndExecuteQuery(k ,p, alpha, query, req, res){
                      var xhr = new XMLHttpRequest();
                      var data = JSON.stringify({"from" : 0, "size" : k,"query": {"match": {"body": query}}});
                      xhr.addEventListener("readystatechange", function() {
                      if (this.readyState === 4) {
              Severity: Minor
              Found in demo/server/server.js - About 1 hr to fix

                Method generateMtable has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private int[] generateMtable(int k, float p, float a, String id) {
                        //check if the index exists
                        boolean mTableStoreExists = client
                                .admin().indices().prepareExists(ModelStore.STORE_NAME)
                                .get().isExists();

                  Method getRestHandlers has 7 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public List<RestHandler> getRestHandlers(Settings settings, RestController restController,
                                                               ClusterSettings clusterSettings, IndexScopedSettings indexScopedSettings,
                                                               SettingsFilter settingsFilter, IndexNameExpressionResolver indexNameExpressionResolver,
                                                               Supplier<DiscoveryNodes> nodesInCluster) {
                  Severity: Major
                  Found in src/main/java/com/purbon/search/fair/FairSearchQueryParserPlugin.java - About 50 mins to fix

                    Function createMtableAndExecuteQuery has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    function createMtableAndExecuteQuery(k ,p, alpha, query, req, res){
                    Severity: Minor
                    Found in demo/server/server.js - About 45 mins to fix

                      Function executeFairQueryWithAdjustedParameters has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function executeFairQueryWithAdjustedParameters(k,p,alpha,q, req, res){
                      Severity: Minor
                      Found in demo/server/server.js - About 45 mins to fix

                        Method fairTopK has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public TopDocs fairTopK(List<ScoreDoc> npQueue, List<ScoreDoc> pQueue, int k, float p, float alpha) {
                        Severity: Minor
                        Found in src/main/java/com/purbon/search/fair/lib/FairTopKImpl.java - About 35 mins to fix

                          Method fairTopK has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              TopDocs fairTopK(List<ScoreDoc> npQueue, List<ScoreDoc> pQueue, int k, float p, float alpha);
                          Severity: Minor
                          Found in src/main/java/com/purbon/search/fair/lib/FairTopK.java - About 35 mins to fix

                            Method adjustIterative has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private double adjustIterative() {
                                    double adjustedAlpha;
                                    double left = Double.MIN_VALUE;
                                    double right = alpha;
                                    double minOptAlpha = (left + right) / 2.0;

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

                                public Integer getSumOf(String columnName) {
                                    Integer sum = 0;
                                    if (column1Name.equals(columnName)) {
                                        for (Integer i : col1) {
                                            sum += i;
                            Severity: Minor
                            Found in src/main/java/com/purbon/search/fair/utils/DataFrame.java - 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

                            Severity
                            Category
                            Status
                            Source
                            Language