project1-5 / bt

Java BitTorrent library with DHT, magnet links, encryption and more
http://atomashpolskiy.github.io/bt/
Apache License 2.0
0 stars 0 forks source link

The high CCN functions #1

Open jsjolen opened 5 years ago

jsjolen commented 5 years ago

Post the 8 highest CCN functions you found here for comparison.

jsjolen commented 5 years ago

NLOC CCN token PARAM length location

  56     17    422      1      65 Assignments::assign@86-150@bt-core/src/main/java/bt/torrent/messaging/Assignments.java
  57     17    386      2      60 ByteChannelReader::sync@79-138@bt-core/src/main/java/bt/net/ByteChannelReader.java
  57     17    407      2      76 ReadWriteDataRange::getSubrange@146-221@bt-core/src/main/java/bt/data/ReadWriteDataRange.java
  50     17    400      0      58 BtRuntimeBuilder::createInjector@175-232@bt-core/src/main/java/bt/runtime/BtRuntimeBuilder.java
  58     18    467      2      63 Assignments::update@174-236@bt-core/src/main/java/bt/torrent/messaging/Assignments.java
 120     19   1066      1     158 MetadataService::buildTorrent@109-266@bt-core/src/main/java/bt/metainfo/MetadataService.java
  75     20    478      2      81 ConnectionSource::getConnectionAsync@85-165@bt-core/src/main/java/bt/net/ConnectionSource.java
 136     21   1122      4     196 MSEHandshakeProcessor::negotiateIncoming@291-486@bt-core/src/main/java/bt/net/crypto/MSEHandshakeProcessor.java
seven2four83 commented 5 years ago

My CCN instrumentation results.

 !!!! Warnings (cyclomatic_complexity > 15 or length > 1000 or parameter_count > 100) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location  
------------------------------------------------
     113     33    787      1     132 PrettyPrinter::prettyPrintInternal@83-214@./bt-dht/the8472/mldht/src/the8472/bencode/PrettyPrinter.java
      46     19    253      0      52 Tokenizer::tokenize@236-287@./bt-dht/the8472/mldht/src/the8472/bencode/Tokenizer.java
     108     19    668      0     143 Server::accept@96-238@./bt-dht/the8472/mldht/src/the8472/mldht/cli/Server.java
      70     19    715      0     101 TorrentDumper::dumpStats@344-444@./bt-dht/the8472/mldht/src/the8472/mldht/indexing/TorrentDumper.java
      76     21    596      0     106 TorrentFetcher::FetchTask::connections@501-606@./bt-dht/the8472/mldht/src/the8472/mldht/TorrentFetcher.java
     181     46   1325      0     285 PullMetaDataConnection::processInput@329-613@./bt-dht/the8472/mldht/src/the8472/bt/PullMetaDataConnection.java
      40     17    321      2      62 PeerLookupTask::callFinished@125-186@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/tasks/PeerLookupTask.java
      36     17    353      2      55 GetLookupTask::callFinished@110-164@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/tasks/GetLookupTask.java
     113     32   1214      3     148 MessageDecoder::parseResponse@162-309@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/messages/MessageDecoder.java
     107     27   1187      3     137 MessageDecoder::parseRequest@325-461@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/messages/MessageDecoder.java
      56     20    576      1     123 Node::recievedConcurrent@285-407@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/Node.java
      47     18    374      1      70 Node::doBucketChecks@657-726@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/Node.java
      60     20    511      1      86 AnnounceNodeCache::cleanup@210-295@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/AnnounceNodeCache.java
      60     16    446      1      81 IDMismatchDetector::activeCheck@102-182@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/IDMismatchDetector.java
      59     16    492      0      81 RPCServerManager::startNewServers@125-205@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/RPCServerManager.java
      46     22    458      1      69 DHT::getPeers@376-444@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/DHT.java
     103     21   1079      2     150 RPCServer::handlePacket@375-524@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/RPCServer.java
     136     21   1122      4     196 MSEHandshakeProcessor::negotiateIncoming@291-486@./bt-core/src/main/java/bt/net/crypto/MSEHandshakeProcessor.java
      57     17    386      2      60 ByteChannelReader::sync@79-138@./bt-core/src/main/java/bt/net/ByteChannelReader.java
      75     20    478      2      81 ConnectionSource::getConnectionAsync@85-165@./bt-core/src/main/java/bt/net/ConnectionSource.java
      50     17    400      0      58 BtRuntimeBuilder::createInjector@175-232@./bt-core/src/main/java/bt/runtime/BtRuntimeBuilder.java
      56     17    422      1      65 Assignments::assign@86-150@./bt-core/src/main/java/bt/torrent/messaging/Assignments.java
      58     18    467      2      63 Assignments::update@174-236@./bt-core/src/main/java/bt/torrent/messaging/Assignments.java
     120     19   1066      1     158 MetadataService::buildTorrent@109-266@./bt-core/src/main/java/bt/metainfo/MetadataService.java
      57     17    407      2      76 ReadWriteDataRange::getSubrange@146-221@./bt-core/src/main/java/bt/data/ReadWriteDataRange.java
modnikhil commented 5 years ago

Lizard on bt-core gives me what Johan got:

!!!! Warnings (cyclomatic_complexity > 15 or length > 1000 or parameter_count > 100) !!!!

NLOC CCN token PARAM length location

136 21 1122 4 196 MSEHandshakeProcessor::negotiateIncoming@291-486@./src/main/java/bt/net/crypto/MSEHandshakeProcessor.java 75 20 478 2 81 ConnectionSource::getConnectionAsync@85-165@./src/main/java/bt/net/ConnectionSource.java 120 19 1066 1 158 MetadataService::buildTorrent@109-266@./src/main/java/bt/metainfo/MetadataService.java 58 18 467 2 63 Assignments::update@174-236@./src/main/java/bt/torrent/messaging/Assignments.java 57 17 407 2 76 ReadWriteDataRange::getSubrange@146-221@./src/main/java/bt/data/ReadWriteDataRange.java 57 17 386 2 60 ByteChannelReader::sync@79-138@./src/main/java/bt/net/ByteChannelReader.java 50 17 400 0 58 BtRuntimeBuilder::createInjector@175-232@./src/main/java/bt/runtime/BtRuntimeBuilder.java 56 17 422 1 65 Assignments::assign@86-150@./src/main/java/bt/torrent/messaging/Assignments.java

jsjolen commented 5 years ago

It's weird that lizard doesn't give me all the results, because I ran a scrip that went through all of the folders :-/.

modnikhil commented 5 years ago

Shouldn't be a big deal. We can just say we focused on the bt-core module in our report. It's still ~17k LOC

jsjolen commented 5 years ago

True. We don't need to pick the 8 HIGHEST functions it sweems like, as long as they have adequate complexity.

seven2four83 commented 5 years ago

@jsjolen : Just outta curiosity, what do you get when you run only on bt-dht folder?

Because I've worked on the bt-dht folder as there was adequate coverage in the other bt-core functions(with CCN>15)..

jsjolen commented 5 years ago

@seven2four83 , yeah it does get reported in the same way that you described. I think we should take your list of CCN as the correct one.

seven2four83 commented 5 years ago

A few of the bt-core functions already had 100% code coverage. These are the results for lizard -C 10:

=========================================================================================
!!!! Warnings (cyclomatic_complexity > 10 or length > 1000 or parameter_count > 100) !!!!
================================================
  NLOC    CCN   token  PARAM  length  location  
------------------------------------------------
     113     33    787      1     132 PrettyPrinter::prettyPrintInternal@83-214@./bt-dht/the8472/mldht/src/the8472/bencode/PrettyPrinter.java
      46     19    253      0      52 Tokenizer::tokenize@236-287@./bt-dht/the8472/mldht/src/the8472/bencode/Tokenizer.java
      33     11    267      2      46 Tokenizer::parseNum@289-334@./bt-dht/the8472/mldht/src/the8472/bencode/Tokenizer.java
      52     11    334      1      63 BEncoder::encodeInternal@55-117@./bt-dht/the8472/mldht/src/the8472/bencode/BEncoder.java
      78     12    803      1     104 TorrentInfo::main@114-217@./bt-dht/the8472/mldht/src/the8472/mldht/cli/TorrentInfo.java
     108     19    668      0     143 Server::accept@96-238@./bt-dht/the8472/mldht/src/the8472/mldht/cli/Server.java
      70     19    715      0     101 TorrentDumper::dumpStats@344-444@./bt-dht/the8472/mldht/src/the8472/mldht/indexing/TorrentDumper.java
      76     21    596      0     106 TorrentFetcher::FetchTask::connections@501-606@./bt-dht/the8472/mldht/src/the8472/mldht/TorrentFetcher.java
      97     12    761      0     137 Launcher::start@117-253@./bt-dht/the8472/mldht/src/the8472/mldht/Launcher.java
     181     46   1325      0     285 PullMetaDataConnection::processInput@329-613@./bt-dht/the8472/mldht/src/the8472/bt/PullMetaDataConnection.java
      30     15    385      0      39 NodeLookup::update@49-87@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/tasks/NodeLookup.java
      40     17    321      2      62 PeerLookupTask::callFinished@125-186@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/tasks/PeerLookupTask.java
      36     17    353      2      55 GetLookupTask::callFinished@110-164@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/tasks/GetLookupTask.java
      36     11    429      0      50 KeyspaceSampler::update@140-189@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/tasks/KeyspaceSampler.java
      37     11    238      0      48 Task::RPCCallListener@126-173@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/tasks/Task.java
      10     13    115      0      10 PutRequest::validate@111-120@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/messages/PutRequest.java
     113     32   1214      3     148 MessageDecoder::parseResponse@162-309@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/messages/MessageDecoder.java
     107     27   1187      3     137 MessageDecoder::parseRequest@325-461@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/messages/MessageDecoder.java
      12     14    136      1      14 AddressUtils::isGlobalUnicast@72-85@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/utils/AddressUtils.java
      30     14    237      1      42 AddressUtils::getAvailableGloballyRoutableAddrs@179-220@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/utils/AddressUtils.java
      56     20    576      1     123 Node::recievedConcurrent@285-407@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/Node.java
      27     13    326      2      40 Node::insertEntry@449-488@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/Node.java
      47     18    374      1      70 Node::doBucketChecks@657-726@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/Node.java
      41     11    460      0      61 Node::mergeBuckets@755-815@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/Node.java
      59     14    390      1      80 AnnounceNodeCache::add@103-182@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/AnnounceNodeCache.java
      60     20    511      1      86 AnnounceNodeCache::cleanup@210-295@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/AnnounceNodeCache.java
      35     12    308      1      62 KClosestNodesSearch::fill@109-170@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/KClosestNodesSearch.java
      60     16    446      1      81 IDMismatchDetector::activeCheck@102-182@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/IDMismatchDetector.java
      20     12    144      3      26 GenericStorage::putOrUpdate@250-275@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/GenericStorage.java
      59     16    492      0      81 RPCServerManager::startNewServers@125-205@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/RPCServerManager.java
      40     12    187      2      52 RPCCall::stateTransition@194-245@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/RPCCall.java
      46     22    458      1      69 DHT::getPeers@376-444@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/DHT.java
      63     12    514      0      88 DHT::started@742-829@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/DHT.java
     103     21   1079      2     150 RPCServer::handlePacket@375-524@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/RPCServer.java
      57     13    401      0      90 RPCServer::SocketHandler::writeEvent@743-832@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/RPCServer.java
      35     15    238      2      47 KBucket::modifyMainBucket@121-167@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/KBucket.java
      26     12    183      0      30 KBucket::pollVerifiedReplacementEntry@297-326@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/KBucket.java
      31     12    204      1      40 KBucket::insertInReplacementBucket@354-393@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/kad/KBucket.java
      69     15    469      4     100 RadixSort::radixSort@22-121@./bt-dht/the8472/mldht/src/lbms/plugins/mldht/utils/RadixSort.java
     113     11    966      5     169 MSEHandshakeProcessor::negotiateOutgoing@121-289@./bt-core/src/main/java/bt/net/crypto/MSEHandshakeProcessor.java
     136     21   1122      4     196 MSEHandshakeProcessor::negotiateIncoming@291-486@./bt-core/src/main/java/bt/net/crypto/MSEHandshakeProcessor.java
      37     12    187      2      39 MSEHandshakeProcessor::selectPolicy@557-595@./bt-core/src/main/java/bt/net/crypto/MSEHandshakeProcessor.java
      51     11    346      2      56 Buffers::searchPattern@37-92@./bt-core/src/main/java/bt/net/buffer/Buffers.java
      41     12    318      0      43 MessageDispatcher::MessageDispatchingLoop::run@94-136@./bt-core/src/main/java/bt/net/MessageDispatcher.java
      42     12    266      1      45 MessageDispatcher::MessageDispatchingLoop::processConsumerMap@138-182@./bt-core/src/main/java/bt/net/MessageDispatcher.java
      40     11    253      1      43 MessageDispatcher::MessageDispatchingLoop::processSupplierMap@184-226@./bt-core/src/main/java/bt/net/MessageDispatcher.java
      57     17    386      2      60 ByteChannelReader::sync@79-138@./bt-core/src/main/java/bt/net/ByteChannelReader.java
      32     11    208      1      35 ByteChannelReader::read@140-174@./bt-core/src/main/java/bt/net/ByteChannelReader.java
      37     12    216      0      47 DataReceivingLoop::run@98-144@./bt-core/src/main/java/bt/net/DataReceivingLoop.java
      75     20    478      2      81 ConnectionSource::getConnectionAsync@85-165@./bt-core/src/main/java/bt/net/ConnectionSource.java
      50     17    400      0      58 BtRuntimeBuilder::createInjector@175-232@./bt-core/src/main/java/bt/runtime/BtRuntimeBuilder.java
      63     15    478      3      72 UdpMessageWorker::doSend@110-181@./bt-core/src/main/java/bt/tracker/udp/UdpMessageWorker.java
      31     11    166      0      33 UdpMessageWorker::getSocket@183-215@./bt-core/src/main/java/bt/tracker/udp/UdpMessageWorker.java
      43     11    299      1      49 AnnounceMessage::parse@128-176@./bt-core/src/main/java/bt/peer/lan/AnnounceMessage.java
      31     11    265      0      39 PeerRegistry::collectAndVisitPeers@105-143@./bt-core/src/main/java/bt/peer/PeerRegistry.java
      27     11    220      2      33 MetadataConsumer::produce@155-187@./bt-core/src/main/java/bt/torrent/messaging/MetadataConsumer.java
      47     12    254      3      49 TorrentWorker::inspectAssignment@185-233@./bt-core/src/main/java/bt/torrent/messaging/TorrentWorker.java
      56     17    422      1      65 Assignments::assign@86-150@./bt-core/src/main/java/bt/torrent/messaging/Assignments.java
      58     18    467      2      63 Assignments::update@174-236@./bt-core/src/main/java/bt/torrent/messaging/Assignments.java
      40     14    311      3      50 MessagingAgentCompiler::compileType@112-161@./bt-core/src/main/java/bt/torrent/compiler/MessagingAgentCompiler.java
      37     12    325      3      41 RarestFirstSelectionStrategy::getNextPieces@83-123@./bt-core/src/main/java/bt/torrent/RarestFirstSelectionStrategy.java
     120     19   1066      1     158 MetadataService::buildTorrent@109-266@./bt-core/src/main/java/bt/metainfo/MetadataService.java
      42     12    292      0      46 ClasspathApplicationService::ClasspathApplicationService@54-99@./bt-core/src/main/java/bt/service/ClasspathApplicationService.java
      37     13    311      5      41 ReadWriteDataRange::ReadWriteDataRange@70-110@./bt-core/src/main/java/bt/data/ReadWriteDataRange.java
      57     17    407      2      76 ReadWriteDataRange::getSubrange@146-221@./bt-core/src/main/java/bt/data/ReadWriteDataRange.java
      70     11    437      2      87 HttpTracker::buildQuery@156-242@./bt-http-tracker-client/src/main/java/bt/tracker/http/HttpTracker.java
      24     13    150      1      25 HttpTracker::urlEncode@244-268@./bt-http-tracker-client/src/main/java/bt/tracker/http/HttpTracker.java